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 f7d725c88ec0..ba81101c90dd 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-09-28 from -# https://github.com/microsoft/TypeScript/releases/tag/v4.4.3 +# files fetched on 2021-12-10 from +# https://github.com/microsoft/TypeScript/releases/tag/v4.5.2 licenses(["notice"]) # Apache 2.0 exports_files([ 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 4902d45ad317..1885ae3396e0 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.4"; + const versionMajorMinor = "4.5"; /** The version of the TypeScript compiler release */ const version: string; /** @@ -234,228 +234,231 @@ declare namespace ts { 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, + AssertKeyword = 129, + AnyKeyword = 130, + AsyncKeyword = 131, + AwaitKeyword = 132, + BooleanKeyword = 133, + ConstructorKeyword = 134, + DeclareKeyword = 135, + GetKeyword = 136, + InferKeyword = 137, + IntrinsicKeyword = 138, + IsKeyword = 139, + KeyOfKeyword = 140, + ModuleKeyword = 141, + NamespaceKeyword = 142, + NeverKeyword = 143, + ReadonlyKeyword = 144, + RequireKeyword = 145, + NumberKeyword = 146, + ObjectKeyword = 147, + SetKeyword = 148, + StringKeyword = 149, + SymbolKeyword = 150, + TypeKeyword = 151, + UndefinedKeyword = 152, + UniqueKeyword = 153, + UnknownKeyword = 154, + FromKeyword = 155, + GlobalKeyword = 156, + BigIntKeyword = 157, + OverrideKeyword = 158, + OfKeyword = 159, + QualifiedName = 160, + ComputedPropertyName = 161, + TypeParameter = 162, + Parameter = 163, + Decorator = 164, + PropertySignature = 165, + PropertyDeclaration = 166, + MethodSignature = 167, + MethodDeclaration = 168, + ClassStaticBlockDeclaration = 169, + Constructor = 170, + GetAccessor = 171, + SetAccessor = 172, + CallSignature = 173, + ConstructSignature = 174, + IndexSignature = 175, + TypePredicate = 176, + TypeReference = 177, + FunctionType = 178, + ConstructorType = 179, + TypeQuery = 180, + TypeLiteral = 181, + ArrayType = 182, + TupleType = 183, + OptionalType = 184, + RestType = 185, + UnionType = 186, + IntersectionType = 187, + ConditionalType = 188, + InferType = 189, + ParenthesizedType = 190, + ThisType = 191, + TypeOperator = 192, + IndexedAccessType = 193, + MappedType = 194, + LiteralType = 195, + NamedTupleMember = 196, + TemplateLiteralType = 197, + TemplateLiteralTypeSpan = 198, + ImportType = 199, + ObjectBindingPattern = 200, + ArrayBindingPattern = 201, + BindingElement = 202, + ArrayLiteralExpression = 203, + ObjectLiteralExpression = 204, + PropertyAccessExpression = 205, + ElementAccessExpression = 206, + CallExpression = 207, + NewExpression = 208, + TaggedTemplateExpression = 209, + TypeAssertionExpression = 210, + ParenthesizedExpression = 211, + FunctionExpression = 212, + ArrowFunction = 213, + DeleteExpression = 214, + TypeOfExpression = 215, + VoidExpression = 216, + AwaitExpression = 217, + PrefixUnaryExpression = 218, + PostfixUnaryExpression = 219, + BinaryExpression = 220, + ConditionalExpression = 221, + TemplateExpression = 222, + YieldExpression = 223, + SpreadElement = 224, + ClassExpression = 225, + OmittedExpression = 226, + ExpressionWithTypeArguments = 227, + AsExpression = 228, + NonNullExpression = 229, + MetaProperty = 230, + SyntheticExpression = 231, + TemplateSpan = 232, + SemicolonClassElement = 233, + Block = 234, + EmptyStatement = 235, + VariableStatement = 236, + ExpressionStatement = 237, + IfStatement = 238, + DoStatement = 239, + WhileStatement = 240, + ForStatement = 241, + ForInStatement = 242, + ForOfStatement = 243, + ContinueStatement = 244, + BreakStatement = 245, + ReturnStatement = 246, + WithStatement = 247, + SwitchStatement = 248, + LabeledStatement = 249, + ThrowStatement = 250, + TryStatement = 251, + DebuggerStatement = 252, + VariableDeclaration = 253, + VariableDeclarationList = 254, + FunctionDeclaration = 255, + ClassDeclaration = 256, + InterfaceDeclaration = 257, + TypeAliasDeclaration = 258, + EnumDeclaration = 259, + ModuleDeclaration = 260, + ModuleBlock = 261, + CaseBlock = 262, + NamespaceExportDeclaration = 263, + ImportEqualsDeclaration = 264, + ImportDeclaration = 265, + ImportClause = 266, + NamespaceImport = 267, + NamedImports = 268, + ImportSpecifier = 269, + ExportAssignment = 270, + ExportDeclaration = 271, + NamedExports = 272, + NamespaceExport = 273, + ExportSpecifier = 274, + MissingDeclaration = 275, + ExternalModuleReference = 276, + JsxElement = 277, + JsxSelfClosingElement = 278, + JsxOpeningElement = 279, + JsxClosingElement = 280, + JsxFragment = 281, + JsxOpeningFragment = 282, + JsxClosingFragment = 283, + JsxAttribute = 284, + JsxAttributes = 285, + JsxSpreadAttribute = 286, + JsxExpression = 287, + CaseClause = 288, + DefaultClause = 289, + HeritageClause = 290, + CatchClause = 291, + AssertClause = 292, + AssertEntry = 293, + PropertyAssignment = 294, + ShorthandPropertyAssignment = 295, + SpreadAssignment = 296, + EnumMember = 297, + UnparsedPrologue = 298, + UnparsedPrepend = 299, + UnparsedText = 300, + UnparsedInternalText = 301, + UnparsedSyntheticReference = 302, + SourceFile = 303, + Bundle = 304, + UnparsedSource = 305, + InputFiles = 306, + JSDocTypeExpression = 307, + JSDocNameReference = 308, + JSDocMemberName = 309, + JSDocAllType = 310, + JSDocUnknownType = 311, + JSDocNullableType = 312, + JSDocNonNullableType = 313, + JSDocOptionalType = 314, + JSDocFunctionType = 315, + JSDocVariadicType = 316, + JSDocNamepathType = 317, + JSDocComment = 318, + JSDocText = 319, + JSDocTypeLiteral = 320, + JSDocSignature = 321, + JSDocLink = 322, + JSDocLinkCode = 323, + JSDocLinkPlain = 324, + JSDocTag = 325, + JSDocAugmentsTag = 326, + JSDocImplementsTag = 327, + JSDocAuthorTag = 328, + JSDocDeprecatedTag = 329, + JSDocClassTag = 330, + JSDocPublicTag = 331, + JSDocPrivateTag = 332, + JSDocProtectedTag = 333, + JSDocReadonlyTag = 334, + JSDocOverrideTag = 335, + JSDocCallbackTag = 336, + JSDocEnumTag = 337, + JSDocParameterTag = 338, + JSDocReturnTag = 339, + JSDocThisTag = 340, + JSDocTypeTag = 341, + JSDocTemplateTag = 342, + JSDocTypedefTag = 343, + JSDocSeeTag = 344, + JSDocPropertyTag = 345, + SyntaxList = 346, + NotEmittedStatement = 347, + PartiallyEmittedExpression = 348, + CommaListExpression = 349, + MergeDeclarationMarker = 350, + EndOfDeclarationMarker = 351, + SyntheticReferenceExpression = 352, + Count = 353, FirstAssignment = 63, LastAssignment = 78, FirstCompoundAssignment = 64, @@ -463,15 +466,15 @@ declare namespace ts { FirstReservedWord = 81, LastReservedWord = 116, FirstKeyword = 81, - LastKeyword = 158, + LastKeyword = 159, FirstFutureReservedWord = 117, LastFutureReservedWord = 125, - FirstTypeNode = 175, - LastTypeNode = 198, + FirstTypeNode = 176, + LastTypeNode = 199, FirstPunctuation = 18, LastPunctuation = 78, FirstToken = 0, - LastToken = 158, + LastToken = 159, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -480,19 +483,19 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 29, LastBinaryOperator = 78, - FirstStatement = 235, - LastStatement = 251, - FirstNode = 159, - FirstJSDocNode = 304, - LastJSDocNode = 342, - FirstJSDocTagNode = 322, - LastJSDocTagNode = 342, + FirstStatement = 236, + LastStatement = 252, + FirstNode = 160, + FirstJSDocNode = 307, + LastJSDocNode = 345, + FirstJSDocTagNode = 325, + LastJSDocTagNode = 345, } 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.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 KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | 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; @@ -597,6 +600,7 @@ declare namespace ts { export interface KeywordToken extends Token { } export type AssertsKeyword = KeywordToken; + export type AssertKeyword = KeywordToken; export type AwaitKeyword = KeywordToken; /** @deprecated Use `AwaitKeyword` instead. */ export type AwaitKeywordToken = AwaitKeyword; @@ -666,7 +670,7 @@ declare namespace ts { readonly parent: Declaration; readonly expression: Expression; } - export interface PrivateIdentifier extends Node { + export interface PrivateIdentifier extends PrimaryExpression { readonly kind: SyntaxKind.PrivateIdentifier; readonly escapedText: __String; } @@ -969,6 +973,8 @@ declare namespace ts { readonly nameType?: TypeNode; readonly questionToken?: QuestionToken | PlusToken | MinusToken; readonly type?: TypeNode; + /** Used only to produce grammar errors */ + readonly members?: NodeArray; } export interface LiteralTypeNode extends TypeNode { readonly kind: SyntaxKind.LiteralType; @@ -1381,13 +1387,13 @@ declare namespace ts { } export interface JsxExpression extends Expression { readonly kind: SyntaxKind.JsxExpression; - readonly parent: JsxElement | JsxAttributeLike; + readonly parent: JsxElement | JsxFragment | JsxAttributeLike; readonly dotDotDotToken?: Token; readonly expression?: Expression; } export interface JsxText extends LiteralLikeNode { readonly kind: SyntaxKind.JsxText; - readonly parent: JsxElement; + readonly parent: JsxElement | JsxFragment; readonly containsOnlyTriviaWhiteSpaces: boolean; } export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; @@ -1630,6 +1636,7 @@ declare namespace ts { readonly importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ readonly moduleSpecifier: Expression; + readonly assertClause?: AssertClause; } export type NamedImportBindings = NamespaceImport | NamedImports; export type NamedExportBindings = NamespaceExport | NamedExports; @@ -1640,6 +1647,19 @@ declare namespace ts { readonly name?: Identifier; readonly namedBindings?: NamedImportBindings; } + export type AssertionKey = Identifier | StringLiteral; + export interface AssertEntry extends Node { + readonly kind: SyntaxKind.AssertEntry; + readonly parent: AssertClause; + readonly name: AssertionKey; + readonly value: StringLiteral; + } + export interface AssertClause extends Node { + readonly kind: SyntaxKind.AssertClause; + readonly parent: ImportDeclaration | ExportDeclaration; + readonly elements: NodeArray; + readonly multiLine?: boolean; + } export interface NamespaceImport extends NamedDeclaration { readonly kind: SyntaxKind.NamespaceImport; readonly parent: ImportClause; @@ -1662,6 +1682,7 @@ declare namespace ts { readonly exportClause?: NamedExportBindings; /** If this is not a StringLiteral it will be a grammar error. */ readonly moduleSpecifier?: Expression; + readonly assertClause?: AssertClause; } export interface NamedImports extends Node { readonly kind: SyntaxKind.NamedImports; @@ -1679,15 +1700,39 @@ declare namespace ts { readonly parent: NamedImports; readonly propertyName?: Identifier; readonly name: Identifier; + readonly isTypeOnly: boolean; } export interface ExportSpecifier extends NamedDeclaration { readonly kind: SyntaxKind.ExportSpecifier; readonly parent: NamedExports; + readonly isTypeOnly: boolean; readonly propertyName?: Identifier; readonly name: Identifier; } export type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; export type TypeOnlyCompatibleAliasDeclaration = ImportClause | ImportEqualsDeclaration | NamespaceImport | ImportOrExportSpecifier; + export type TypeOnlyAliasDeclaration = ImportClause & { + readonly isTypeOnly: true; + readonly name: Identifier; + } | ImportEqualsDeclaration & { + readonly isTypeOnly: true; + } | NamespaceImport & { + readonly parent: ImportClause & { + readonly isTypeOnly: true; + }; + } | ImportSpecifier & { + readonly parent: NamedImports & { + readonly parent: ImportClause & { + readonly isTypeOnly: true; + }; + }; + } | ExportSpecifier & { + readonly parent: NamedExports & { + readonly parent: ExportDeclaration & { + readonly isTypeOnly: true; + }; + }; + }; /** * This is either an `export =` or an `export default` declaration. * Unless `isExportEquals` is set, this node was parsed as an `export default`. @@ -1925,7 +1970,7 @@ declare namespace ts { id?: number; } export interface FlowStart extends FlowNodeBase { - node?: FunctionExpression | ArrowFunction | MethodDeclaration; + node?: FunctionExpression | ArrowFunction | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration; } export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; @@ -1989,6 +2034,18 @@ declare namespace ts { */ hasNoDefaultLib: boolean; languageVersion: ScriptTarget; + /** + * When `module` is `Node12` or `NodeNext`, this field controls whether the + * source file in question is an ESNext-output-format file, or a CommonJS-output-format + * module. This is derived by the module resolver as it looks up the file, since + * it is derived from either the file extension of the module, or the containing + * `package.json` context, and affects both checking and emit. + * + * It is _public_ so that (pre)transformers can set this field, + * since it switches the builtin `node` module transform. Generally speaking, if unset, + * the field is treated as though it is `ModuleKind.CommonJS`. + */ + impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; } export interface Bundle extends Node { readonly kind: SyntaxKind.Bundle; @@ -2282,6 +2339,7 @@ declare namespace ts { getApparentType(type: Type): Type; getBaseConstraintOfType(type: Type): Type | undefined; getDefaultFromTypeParameter(type: Type): Type | undefined; + getTypePredicateOfSignature(signature: Signature): TypePredicate | undefined; /** * Depending on the operation performed, it may be appropriate to throw away the checker * if the cancellation token is triggered. Typically, if it is used for error checking @@ -2699,8 +2757,8 @@ declare namespace ts { root: ConditionalRoot; checkType: Type; extendsType: Type; - resolvedTrueType: Type; - resolvedFalseType: Type; + resolvedTrueType?: Type; + resolvedFalseType?: Type; } export interface TemplateLiteralType extends InstantiableType { texts: readonly string[]; @@ -2805,7 +2863,9 @@ declare namespace ts { } export enum ModuleResolutionKind { Classic = 1, - NodeJs = 2 + NodeJs = 2, + Node12 = 3, + NodeNext = 99 } export interface PluginImport { name: string; @@ -2903,6 +2963,7 @@ declare namespace ts { preserveConstEnums?: boolean; noImplicitOverride?: boolean; preserveSymlinks?: boolean; + preserveValueImports?: boolean; project?: string; reactNamespace?: string; jsxFactory?: string; @@ -2966,7 +3027,10 @@ declare namespace ts { System = 4, ES2015 = 5, ES2020 = 6, - ESNext = 99 + ES2022 = 7, + ESNext = 99, + Node12 = 100, + NodeNext = 199 } export enum JsxEmit { None = 0, @@ -3058,6 +3122,7 @@ declare namespace ts { realpath?(path: string): string; getCurrentDirectory?(): string; getDirectories?(path: string): string[]; + useCaseSensitiveFileNames?: boolean | (() => boolean); } /** * Represents the result of module resolution. @@ -3111,7 +3176,13 @@ declare namespace ts { Js = ".js", Jsx = ".jsx", Json = ".json", - TsBuildInfo = ".tsbuildinfo" + TsBuildInfo = ".tsbuildinfo", + Mjs = ".mjs", + Mts = ".mts", + Dmts = ".d.mts", + Cjs = ".cjs", + Cts = ".cts", + Dcts = ".d.cts" } export interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; @@ -3139,7 +3210,11 @@ declare namespace ts { useCaseSensitiveFileNames(): boolean; getNewLine(): string; readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; + /** + * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + */ + getModuleResolutionCache?(): ModuleResolutionCache | undefined; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ @@ -3218,7 +3293,8 @@ declare namespace ts { NonNullAssertions = 4, PartiallyEmittedExpressions = 8, Assertions = 6, - All = 15 + All = 15, + ExcludeJSDocTypeAssertion = 16 } export type TypeOfTag = "undefined" | "number" | "bigint" | "boolean" | "string" | "symbol" | "object" | "function"; export interface NodeFactory { @@ -3346,8 +3422,8 @@ declare namespace ts { updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; - createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; - updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; + createMappedTypeNode(readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray | undefined): MappedTypeNode; + updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray | undefined): MappedTypeNode; createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; createTemplateLiteralType(head: TemplateHead, templateSpans: readonly TemplateLiteralTypeSpan[]): TemplateLiteralTypeNode; @@ -3493,26 +3569,30 @@ declare namespace ts { updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause): ImportDeclaration; + updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; + createAssertClause(elements: NodeArray, multiLine?: boolean): AssertClause; + updateAssertClause(node: AssertClause, elements: NodeArray, multiLine?: boolean): AssertClause; + createAssertEntry(name: AssertionKey, value: StringLiteral): AssertEntry; + updateAssertEntry(node: AssertEntry, name: AssertionKey, value: StringLiteral): AssertEntry; createNamespaceImport(name: Identifier): NamespaceImport; updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; createNamespaceExport(name: Identifier): NamespaceExport; updateNamespaceExport(node: NamespaceExport, name: Identifier): NamespaceExport; createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; - createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; + createImportSpecifier(isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; + updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; - createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression): ExportDeclaration; - updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; + updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; - createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; - updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; + createExportSpecifier(isTypeOnly: boolean, propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; + updateExportSpecifier(node: ExportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; createExternalModuleReference(expression: Expression): ExternalModuleReference; updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; createJSDocAllType(): JSDocAllType; @@ -3619,7 +3699,7 @@ declare namespace ts { updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; - createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; + createCatchClause(variableDeclaration: string | BindingName | VariableDeclaration | undefined, block: Block): CatchClause; updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; @@ -3925,6 +4005,7 @@ declare namespace ts { ObjectBindingPatternElements = 525136, ArrayBindingPatternElements = 524880, ObjectLiteralExpressionProperties = 526226, + ImportClauseEntries = 526226, ArrayLiteralExpressionElements = 8914, CommaListElements = 528, CallExpressionArguments = 2576, @@ -3961,6 +4042,7 @@ declare namespace ts { readonly includeCompletionsWithSnippetText?: boolean; readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; + readonly includeCompletionsWithClassMemberSnippets?: 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" */ @@ -3969,6 +4051,7 @@ declare namespace ts { readonly providePrefixAndSuffixTextForRename?: boolean; readonly includePackageJsonAutoImports?: "auto" | "on" | "off"; readonly provideRefactorNotApplicableReason?: boolean; + readonly jsxAttributeCompletionStyle?: "auto" | "braces" | "none"; } /** Represents a bigint literal value without requiring bigint support */ export interface PseudoBigInt { @@ -4318,7 +4401,8 @@ declare namespace ts { function isTemplateLiteralToken(node: Node): node is TemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; function isImportOrExportSpecifier(node: Node): node is ImportSpecifier | ExportSpecifier; - function isTypeOnlyImportOrExportDeclaration(node: Node): node is TypeOnlyCompatibleAliasDeclaration; + function isTypeOnlyImportOrExportDeclaration(node: Node): node is TypeOnlyAliasDeclaration; + function isAssertionKey(node: Node): node is AssertionKey; function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken; function isModifier(node: Node): node is Modifier; function isEntityName(node: Node): node is EntityName; @@ -4566,6 +4650,8 @@ declare namespace ts { function isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration; function isImportDeclaration(node: Node): node is ImportDeclaration; function isImportClause(node: Node): node is ImportClause; + function isAssertClause(node: Node): node is AssertClause; + function isAssertEntry(node: Node): node is AssertEntry; function isNamespaceImport(node: Node): node is NamespaceImport; function isNamespaceExport(node: Node): node is NamespaceExport; function isNamedImports(node: Node): node is NamedImports; @@ -4776,12 +4862,20 @@ declare namespace ts { export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache, PackageJsonInfoCache { } + export interface ModeAwareCache { + get(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): T | undefined; + set(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, value: T): this; + delete(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): this; + has(key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined): boolean; + forEach(cb: (elem: T, key: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined) => void): void; + size(): number; + } /** * Cached resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ export interface PerDirectoryResolutionCache { - getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): ModeAwareCache; clear(): void; /** * Updates with the current compilerOptions the cache will operate with. @@ -4797,7 +4891,7 @@ declare namespace ts { * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache { - getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; + getOrCreateCacheForModuleName(nonRelativeModuleName: string, mode: ModuleKind.CommonJS | ModuleKind.ESNext | undefined, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } export interface PackageJsonInfoCache { clear(): void; @@ -4808,8 +4902,8 @@ declare namespace ts { } export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache; - export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; - export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache, mode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined; + export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations; export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export {}; @@ -4920,6 +5014,17 @@ declare namespace ts { export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; + /** + * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the + * `options` parameter. + * + * @param fileName The normalized absolute path to check the format of (it need not exist on disk) + * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often + * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data + * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution` + * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format + */ + export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -5164,7 +5269,7 @@ declare namespace ts { /** If provided is used to get the environment variable */ getEnvironmentVariable?(name: string): string | undefined; /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; } @@ -5554,8 +5659,8 @@ declare namespace ts { realpath?(path: string): string; fileExists?(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; - getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; + getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedTypeReferenceDirective | undefined)[]; getDirectories?(directoryName: string): string[]; /** @@ -6265,23 +6370,28 @@ declare namespace ts { isIncomplete?: true; entries: CompletionEntry[]; } - interface CompletionEntryData { - /** The file name declaring the export's module symbol, if it was an external module */ - fileName?: string; - /** The module name (with quotes stripped) of the export's module symbol, if it was an ambient module */ - ambientModuleName?: string; - /** True if the export was found in the package.json AutoImportProvider */ - isPackageJsonImport?: true; + interface CompletionEntryDataAutoImport { /** * The name of the property or export in the module's symbol table. Differs from the completion name * in the case of InternalSymbolName.ExportEquals and InternalSymbolName.Default. */ exportName: string; - /** - * Set for auto imports with eagerly resolved module specifiers. - */ moduleSpecifier?: string; + /** The file name declaring the export's module symbol, if it was an external module */ + fileName?: string; + /** The module name (with quotes stripped) of the export's module symbol, if it was an ambient module */ + ambientModuleName?: string; + /** True if the export was found in the package.json AutoImportProvider */ + isPackageJsonImport?: true; + } + interface CompletionEntryDataUnresolved extends CompletionEntryDataAutoImport { + /** The key in the `ExportMapCache` where the completion entry's `SymbolExportInfo[]` is found */ + exportMapKey: string; + } + interface CompletionEntryDataResolved extends CompletionEntryDataAutoImport { + moduleSpecifier: string; } + type CompletionEntryData = CompletionEntryDataUnresolved | CompletionEntryDataResolved; interface CompletionEntry { name: string; kind: ScriptElementKind; @@ -6503,7 +6613,13 @@ declare namespace ts { tsxModifier = ".tsx", jsModifier = ".js", jsxModifier = ".jsx", - jsonModifier = ".json" + jsonModifier = ".json", + dmtsModifier = ".d.mts", + mtsModifier = ".mts", + mjsModifier = ".mjs", + dctsModifier = ".d.cts", + ctsModifier = ".cts", + cjsModifier = ".cjs" } enum ClassificationTypeNames { comment = "comment", @@ -6865,9 +6981,9 @@ declare namespace ts { /** @deprecated Use `factory.updateIndexedAccessTypeNode` or the factory supplied by your transformation context instead. */ const updateIndexedAccessTypeNode: (node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode) => IndexedAccessTypeNode; /** @deprecated Use `factory.createMappedTypeNode` or the factory supplied by your transformation context instead. */ - const createMappedTypeNode: (readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined) => MappedTypeNode; + const createMappedTypeNode: (readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray | undefined) => MappedTypeNode; /** @deprecated Use `factory.updateMappedTypeNode` or the factory supplied by your transformation context instead. */ - const updateMappedTypeNode: (node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined) => MappedTypeNode; + const updateMappedTypeNode: (node: MappedTypeNode, readonlyToken: ReadonlyKeyword | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, nameType: TypeNode | undefined, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined, members: NodeArray | undefined) => MappedTypeNode; /** @deprecated Use `factory.createLiteralTypeNode` or the factory supplied by your transformation context instead. */ const createLiteralTypeNode: (literal: LiteralExpression | BooleanLiteral | PrefixUnaryExpression | NullLiteral) => LiteralTypeNode; /** @deprecated Use `factory.updateLiteralTypeNode` or the factory supplied by your transformation context instead. */ @@ -7135,9 +7251,9 @@ declare namespace ts { /** @deprecated Use `factory.updateImportEqualsDeclaration` or the factory supplied by your transformation context instead. */ const updateImportEqualsDeclaration: (node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference) => ImportEqualsDeclaration; /** @deprecated Use `factory.createImportDeclaration` or the factory supplied by your transformation context instead. */ - const createImportDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression) => ImportDeclaration; + const createImportDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause | undefined) => ImportDeclaration; /** @deprecated Use `factory.updateImportDeclaration` or the factory supplied by your transformation context instead. */ - const updateImportDeclaration: (node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression) => ImportDeclaration; + const updateImportDeclaration: (node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined) => ImportDeclaration; /** @deprecated Use `factory.createNamespaceImport` or the factory supplied by your transformation context instead. */ const createNamespaceImport: (name: Identifier) => NamespaceImport; /** @deprecated Use `factory.updateNamespaceImport` or the factory supplied by your transformation context instead. */ @@ -7147,9 +7263,9 @@ declare namespace ts { /** @deprecated Use `factory.updateNamedImports` or the factory supplied by your transformation context instead. */ const updateNamedImports: (node: NamedImports, elements: readonly ImportSpecifier[]) => NamedImports; /** @deprecated Use `factory.createImportSpecifier` or the factory supplied by your transformation context instead. */ - const createImportSpecifier: (propertyName: Identifier | undefined, name: Identifier) => ImportSpecifier; + const createImportSpecifier: (isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier) => ImportSpecifier; /** @deprecated Use `factory.updateImportSpecifier` or the factory supplied by your transformation context instead. */ - const updateImportSpecifier: (node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier) => ImportSpecifier; + const updateImportSpecifier: (node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier) => ImportSpecifier; /** @deprecated Use `factory.createExportAssignment` or the factory supplied by your transformation context instead. */ const createExportAssignment: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression) => ExportAssignment; /** @deprecated Use `factory.updateExportAssignment` or the factory supplied by your transformation context instead. */ @@ -7159,9 +7275,9 @@ declare namespace ts { /** @deprecated Use `factory.updateNamedExports` or the factory supplied by your transformation context instead. */ const updateNamedExports: (node: NamedExports, elements: readonly ExportSpecifier[]) => NamedExports; /** @deprecated Use `factory.createExportSpecifier` or the factory supplied by your transformation context instead. */ - const createExportSpecifier: (propertyName: string | Identifier | undefined, name: string | Identifier) => ExportSpecifier; + const createExportSpecifier: (isTypeOnly: boolean, propertyName: string | Identifier | undefined, name: string | Identifier) => ExportSpecifier; /** @deprecated Use `factory.updateExportSpecifier` or the factory supplied by your transformation context instead. */ - const updateExportSpecifier: (node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier) => ExportSpecifier; + const updateExportSpecifier: (node: ExportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier) => ExportSpecifier; /** @deprecated Use `factory.createExternalModuleReference` or the factory supplied by your transformation context instead. */ const createExternalModuleReference: (expression: Expression) => ExternalModuleReference; /** @deprecated Use `factory.updateExternalModuleReference` or the factory supplied by your transformation context instead. */ @@ -7271,7 +7387,7 @@ declare namespace ts { /** @deprecated Use `factory.updateHeritageClause` or the factory supplied by your transformation context instead. */ const updateHeritageClause: (node: HeritageClause, types: readonly ExpressionWithTypeArguments[]) => HeritageClause; /** @deprecated Use `factory.createCatchClause` or the factory supplied by your transformation context instead. */ - const createCatchClause: (variableDeclaration: string | VariableDeclaration | undefined, block: Block) => CatchClause; + const createCatchClause: (variableDeclaration: string | VariableDeclaration | BindingName | undefined, block: Block) => CatchClause; /** @deprecated Use `factory.updateCatchClause` or the factory supplied by your transformation context instead. */ const updateCatchClause: (node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block) => CatchClause; /** @deprecated Use `factory.createPropertyAssignment` 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 ebd4c15a2a6a..6076298b6efe 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 @@ -290,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.4"; + ts.versionMajorMinor = "4.5"; // 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.4.3"; + ts.version = "4.5.2"; /* @internal */ var Comparison; (function (Comparison) { @@ -323,21 +323,24 @@ var ts; return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined; } NativeCollections.tryGetNativeSet = tryGetNativeSet; - })(NativeCollections = ts.NativeCollections || (ts.NativeCollections = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { + })(NativeCollections || (NativeCollections = {})); + /* @internal */ + ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim"); + /* @internal */ + ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim"); + /* @internal */ function getCollectionImplementation(name, nativeFactory, shimFactory) { var _a; // NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it. - var constructor = (_a = ts.NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](getIterator); + var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); } - ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim"); - ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim"); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { function getIterator(iterable) { if (iterable) { if (isArray(iterable)) @@ -1702,19 +1705,29 @@ var ts; function noop(_) { } ts.noop = noop; /** Do nothing and return false */ - function returnFalse() { return false; } + function returnFalse() { + return false; + } ts.returnFalse = returnFalse; /** Do nothing and return true */ - function returnTrue() { return true; } + function returnTrue() { + return true; + } ts.returnTrue = returnTrue; /** Do nothing and return undefined */ - function returnUndefined() { return undefined; } + function returnUndefined() { + return undefined; + } ts.returnUndefined = returnUndefined; /** Returns its argument. */ - function identity(x) { return x; } + function identity(x) { + return x; + } ts.identity = identity; /** Returns lower case string */ - function toLowerCase(x) { return x.toLowerCase(); } + function toLowerCase(x) { + return x.toLowerCase(); + } ts.toLowerCase = toLowerCase; // We convert the file names to lower case as key for file name on case insensitive file system // While doing so we need to handle special characters (eg \u0130) to ensure that we dont convert @@ -2732,6 +2745,10 @@ var ts; return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false); } Debug.formatSyntaxKind = formatSyntaxKind; + function formatSnippetKind(kind) { + return formatEnum(kind, ts.SnippetKind, /*isFlags*/ false); + } + Debug.formatSnippetKind = formatSnippetKind; function formatNodeFlags(flags) { return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true); } @@ -4151,248 +4168,251 @@ var ts; 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"; + SyntaxKind[SyntaxKind["AssertKeyword"] = 129] = "AssertKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 130] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 131] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 132] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 133] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 134] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 135] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 136] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 137] = "InferKeyword"; + SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 138] = "IntrinsicKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 139] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 140] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 141] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 142] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 143] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 144] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 145] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 146] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 147] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 148] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 149] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 150] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 151] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 152] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 153] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 154] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 155] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 156] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 157] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OverrideKeyword"] = 158] = "OverrideKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 159] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 159] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 160] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 160] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 161] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 161] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 162] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 163] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 162] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 163] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 164] = "Decorator"; // TypeMember - 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"; + SyntaxKind[SyntaxKind["PropertySignature"] = 165] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 166] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 167] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 168] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["ClassStaticBlockDeclaration"] = 169] = "ClassStaticBlockDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 170] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 171] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 172] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 173] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 174] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 175] = "IndexSignature"; // Type - 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"; + SyntaxKind[SyntaxKind["TypePredicate"] = 176] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 177] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 178] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 179] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 180] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 181] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 182] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 183] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 184] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 185] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 186] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 187] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 188] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 189] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 190] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 191] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 192] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 193] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 194] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 195] = "LiteralType"; + SyntaxKind[SyntaxKind["NamedTupleMember"] = 196] = "NamedTupleMember"; + SyntaxKind[SyntaxKind["TemplateLiteralType"] = 197] = "TemplateLiteralType"; + SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 198] = "TemplateLiteralTypeSpan"; + SyntaxKind[SyntaxKind["ImportType"] = 199] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 199] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 200] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 201] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 200] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 201] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 202] = "BindingElement"; // Expression - 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"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 203] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 204] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 205] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 206] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 207] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 208] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 209] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 210] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 211] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 212] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 213] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 214] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 215] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 216] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 217] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 218] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 219] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 220] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 221] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 222] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 223] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 224] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 225] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 226] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 227] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 228] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 229] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 230] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 231] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 231] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 232] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 232] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 233] = "SemicolonClassElement"; // Element - 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"; + SyntaxKind[SyntaxKind["Block"] = 234] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 235] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 236] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 237] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 238] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 239] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 240] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 241] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 242] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 243] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 244] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 245] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 246] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 247] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 248] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 249] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 250] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 251] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 252] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 253] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 254] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 255] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 256] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 257] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 258] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 259] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 260] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 261] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 262] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 263] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 264] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 265] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 266] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 267] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 268] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 269] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 270] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 271] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 272] = "NamedExports"; + SyntaxKind[SyntaxKind["NamespaceExport"] = 273] = "NamespaceExport"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 274] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 275] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 275] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 276] = "ExternalModuleReference"; // JSX - 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"; + SyntaxKind[SyntaxKind["JsxElement"] = 277] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 278] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 279] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 280] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 281] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 282] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 283] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 284] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 285] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 286] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 287] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 287] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 288] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 289] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 290] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 288] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 289] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 290] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 291] = "CatchClause"; + SyntaxKind[SyntaxKind["AssertClause"] = 292] = "AssertClause"; + SyntaxKind[SyntaxKind["AssertEntry"] = 293] = "AssertEntry"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 291] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 292] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 293] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 294] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 295] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 296] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 294] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 297] = "EnumMember"; // Unparsed - 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"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 298] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 299] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 300] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 301] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 302] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 300] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 301] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 302] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 303] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 303] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 304] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 305] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 306] = "InputFiles"; // JSDoc nodes - 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"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 307] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocNameReference"] = 308] = "JSDocNameReference"; + SyntaxKind[SyntaxKind["JSDocMemberName"] = 309] = "JSDocMemberName"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 310] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 311] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 312] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 313] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 314] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 315] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 316] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 317] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 318] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocText"] = 319] = "JSDocText"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 320] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 321] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocLink"] = 322] = "JSDocLink"; + SyntaxKind[SyntaxKind["JSDocLinkCode"] = 323] = "JSDocLinkCode"; + SyntaxKind[SyntaxKind["JSDocLinkPlain"] = 324] = "JSDocLinkPlain"; + SyntaxKind[SyntaxKind["JSDocTag"] = 325] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 326] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 327] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 328] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 329] = "JSDocDeprecatedTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 330] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 331] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 332] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 333] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 334] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 335] = "JSDocOverrideTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 336] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 337] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 338] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 339] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 340] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 341] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 342] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 343] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocSeeTag"] = 344] = "JSDocSeeTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 345] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 343] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 346] = "SyntaxList"; // Transformation nodes - 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"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 347] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 348] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 349] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 350] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 351] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 352] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 350] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 353] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 63] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 78] = "LastAssignment"; @@ -4401,15 +4421,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 81] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 116] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 81] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 158] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 159] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 117] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 125] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 175] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 198] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 176] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 199] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 78] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 158] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 159] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -4418,15 +4438,15 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; 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"; + SyntaxKind[SyntaxKind["FirstStatement"] = 236] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 252] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 160] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 307] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 345] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 325] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 345] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 158] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 159] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -4645,6 +4665,13 @@ var ts; ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ + var MemberOverrideStatus; + (function (MemberOverrideStatus) { + MemberOverrideStatus[MemberOverrideStatus["Ok"] = 0] = "Ok"; + MemberOverrideStatus[MemberOverrideStatus["NeedsOverride"] = 1] = "NeedsOverride"; + MemberOverrideStatus[MemberOverrideStatus["HasInvalidOverride"] = 2] = "HasInvalidOverride"; + })(MemberOverrideStatus = ts.MemberOverrideStatus || (ts.MemberOverrideStatus = {})); + /* @internal */ var UnionReduction; (function (UnionReduction) { UnionReduction[UnionReduction["None"] = 0] = "None"; @@ -4915,6 +4942,7 @@ var ts; CheckFlags[CheckFlags["HasNeverType"] = 131072] = "HasNeverType"; CheckFlags[CheckFlags["Mapped"] = 262144] = "Mapped"; CheckFlags[CheckFlags["StripOptional"] = 524288] = "StripOptional"; + CheckFlags[CheckFlags["Unresolved"] = 1048576] = "Unresolved"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant"; CheckFlags[CheckFlags["Partial"] = 48] = "Partial"; @@ -5039,20 +5067,22 @@ var ts; // '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"; - /* @internal */ - TypeFlags[TypeFlags["NotPrimitiveUnion"] = 468598819] = "NotPrimitiveUnion"; // The following flags are aggregated during union and intersection type construction /* @internal */ TypeFlags[TypeFlags["IncludesMask"] = 205258751] = "IncludesMask"; // The following flags are used for different purposes during union and intersection type construction /* @internal */ - TypeFlags[TypeFlags["IncludesStructuredOrInstantiable"] = 262144] = "IncludesStructuredOrInstantiable"; + TypeFlags[TypeFlags["IncludesMissingType"] = 262144] = "IncludesMissingType"; /* @internal */ TypeFlags[TypeFlags["IncludesNonWideningType"] = 4194304] = "IncludesNonWideningType"; /* @internal */ TypeFlags[TypeFlags["IncludesWildcard"] = 8388608] = "IncludesWildcard"; /* @internal */ TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject"; + /* @internal */ + TypeFlags[TypeFlags["IncludesInstantiable"] = 33554432] = "IncludesInstantiable"; + /* @internal */ + TypeFlags[TypeFlags["NotPrimitiveUnion"] = 36323363] = "NotPrimitiveUnion"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); // Types included in TypeFlags.ObjectFlagsType have an objectFlags property. Some ObjectFlags // are specific to certain types and reuse the same bit position. Those ObjectFlags require a check @@ -5292,6 +5322,12 @@ var ts; (function (ModuleResolutionKind) { ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic"; ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs"; + // Starting with node12, node's module resolver has significant departures from traditional cjs resolution + // to better support ecmascript modules and their use within node - more features are still being added, so + // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` + // version-anchored resolution target + ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12"; + ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext"; })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {})); var WatchFileKind; (function (WatchFileKind) { @@ -5328,7 +5364,11 @@ var ts; // module kind). ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020"; + ModuleKind[ModuleKind["ES2022"] = 7] = "ES2022"; ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext"; + // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext + ModuleKind[ModuleKind["Node12"] = 100] = "Node12"; + ModuleKind[ModuleKind["NodeNext"] = 199] = "NodeNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); var JsxEmit; (function (JsxEmit) { @@ -5528,6 +5568,12 @@ var ts; Extension["Jsx"] = ".jsx"; Extension["Json"] = ".json"; Extension["TsBuildInfo"] = ".tsbuildinfo"; + Extension["Mjs"] = ".mjs"; + Extension["Mts"] = ".mts"; + Extension["Dmts"] = ".d.mts"; + Extension["Cjs"] = ".cjs"; + Extension["Cts"] = ".cts"; + Extension["Dcts"] = ".d.cts"; })(Extension = ts.Extension || (ts.Extension = {})); /* @internal */ var TransformFlags; @@ -5609,6 +5655,15 @@ var ts; // Masks // - Additional bitmasks })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); + // Reference: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax + /* @internal */ + var SnippetKind; + (function (SnippetKind) { + SnippetKind[SnippetKind["TabStop"] = 0] = "TabStop"; + SnippetKind[SnippetKind["Placeholder"] = 1] = "Placeholder"; + SnippetKind[SnippetKind["Choice"] = 2] = "Choice"; + SnippetKind[SnippetKind["Variable"] = 3] = "Variable"; + })(SnippetKind = ts.SnippetKind || (ts.SnippetKind = {})); var EmitFlags; (function (EmitFlags) { EmitFlags[EmitFlags["None"] = 0] = "None"; @@ -5674,9 +5729,10 @@ var ts; ExternalEmitHelpers[ExternalEmitHelpers["MakeTemplateObject"] = 262144] = "MakeTemplateObject"; ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldGet"] = 524288] = "ClassPrivateFieldGet"; ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldSet"] = 1048576] = "ClassPrivateFieldSet"; - ExternalEmitHelpers[ExternalEmitHelpers["CreateBinding"] = 2097152] = "CreateBinding"; + ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldIn"] = 2097152] = "ClassPrivateFieldIn"; + ExternalEmitHelpers[ExternalEmitHelpers["CreateBinding"] = 4194304] = "CreateBinding"; ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; - ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 2097152] = "LastEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 4194304] = "LastEmitHelper"; // Helpers included by ES2015 for..of ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes"; // Helpers included by ES2017 for..await..of @@ -5706,6 +5762,7 @@ var ts; OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 8] = "PartiallyEmittedExpressions"; OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 6] = "Assertions"; OuterExpressionKinds[OuterExpressionKinds["All"] = 15] = "All"; + OuterExpressionKinds[OuterExpressionKinds["ExcludeJSDocTypeAssertion"] = 16] = "ExcludeJSDocTypeAssertion"; })(OuterExpressionKinds = ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); /* @internal */ var LexicalEnvironmentFlags; @@ -5776,6 +5833,7 @@ var ts; ListFormat[ListFormat["ObjectBindingPatternElements"] = 525136] = "ObjectBindingPatternElements"; ListFormat[ListFormat["ArrayBindingPatternElements"] = 524880] = "ArrayBindingPatternElements"; ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 526226] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ImportClauseEntries"] = 526226] = "ImportClauseEntries"; ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 8914] = "ArrayLiteralExpressionElements"; ListFormat[ListFormat["CommaListElements"] = 528] = "CommaListElements"; ListFormat[ListFormat["CallExpressionArguments"] = 2576] = "CallExpressionArguments"; @@ -6858,9 +6916,8 @@ var ts; function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" - if (!ts.isString(relativeFileName)) { + if (!ts.isString(relativeFileName)) return; - } var fileName = ts.getNormalizedAbsolutePath(relativeFileName, dirName); // Some applications save a working file via rename operations var callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName)); @@ -7423,7 +7480,7 @@ var ts; var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin"; var platform = _os.platform(); var useCaseSensitiveFileNames = isFileSystemCaseSensitive(); - var realpathSync = useCaseSensitiveFileNames ? ((_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync) : _fs.realpathSync; + var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync; var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); var getCurrentDirectory = ts.memoize(function () { return process.cwd(); }); var _c = createSystemWatchFunctions({ @@ -7900,7 +7957,7 @@ var ts; } } function readDirectory(path, extensions, excludes, includes, depth) { - return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath, directoryExists); + return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath); } function fileSystemEntryExists(path, entryKind) { // Since the error thrown by fs.statSync isn't used, we can avoid collecting a stack trace to improve @@ -7985,6 +8042,11 @@ var ts; } return sys; })(); + /*@internal*/ + function setSys(s) { + ts.sys = s; + } + ts.setSys = setSys; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) @@ -8035,11 +8097,8 @@ var ts; A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), - _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), - _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), - A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), @@ -8050,7 +8109,6 @@ var ts; A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), - An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), @@ -8179,7 +8237,6 @@ var ts; Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "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."), - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), @@ -8212,7 +8269,6 @@ var ts; Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), @@ -8240,9 +8296,9 @@ var ts; Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'."), - Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), - Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd__1323", "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'."), + Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext_1324", "Dynamic imports only support a second argument when the '--module' option is set to 'esnext'."), + Argument_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Argument_of_dynamic_import_cannot_be_spread_element_1325", "Argument of dynamic import cannot be spread element."), Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."), String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), @@ -8258,7 +8314,7 @@ var ts; 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}')'?"), Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system__1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'es2022', 'esnext', 'system', 'node12', or 'nodenext'."), A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness."), This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), @@ -8275,7 +8331,6 @@ var ts; An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."), - Did_you_mean_to_parenthesize_this_function_type: diag(1360, ts.DiagnosticCategory.Error, "Did_you_mean_to_parenthesize_this_function_type_1360", "Did you mean to parenthesize this function type?"), _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type: diag(1361, ts.DiagnosticCategory.Error, "_0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type_1361", "'{0}' cannot be used as a value because it was imported using 'import type'."), _0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type: diag(1362, ts.DiagnosticCategory.Error, "_0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type_1362", "'{0}' cannot be used as a value because it was exported using 'export type'."), A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both: diag(1363, ts.DiagnosticCategory.Error, "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363", "A type-only import can specify a default import or named bindings, but not both."), @@ -8290,7 +8345,7 @@ var ts; await_expressions_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(1375, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_fi_1375", "'await' expressions 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."), _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."), _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."), - Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_t_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), + Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_o_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"), @@ -8302,8 +8357,7 @@ var ts; Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."), Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1388, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1388", "Constructor type notation must be parenthesized when used in an intersection type."), _0_is_not_allowed_as_a_variable_declaration_name: diag(1389, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_variable_declaration_name_1389", "'{0}' is not allowed as a variable declaration name."), - Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."), - The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The 'bundledPackageName' option must be provided when using outFile and node module resolution with declaration emit."), + _0_is_not_allowed_as_a_parameter_name: diag(1390, ts.DiagnosticCategory.Error, "_0_is_not_allowed_as_a_parameter_name_1390", "'{0}' is not allowed as a parameter name."), An_import_alias_cannot_use_import_type: diag(1392, ts.DiagnosticCategory.Error, "An_import_alias_cannot_use_import_type_1392", "An import alias cannot use 'import type'"), Imported_via_0_from_file_1: diag(1393, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_1393", "Imported via {0} from file '{1}'"), Imported_via_0_from_file_1_with_packageId_2: diag(1394, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_1394", "Imported via {0} from file '{1}' with packageId '{2}'"), @@ -8344,7 +8398,7 @@ var ts; File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"), The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"), 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."), + Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_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_es2022_esnext_system_or__1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', or 'nodenext', 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}'?"), @@ -8356,12 +8410,22 @@ var ts; 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."), + _0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled: diag(1444, ts.DiagnosticCategory.Error, "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444", "'{0}' is a type and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled."), + _0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled: diag(1446, ts.DiagnosticCategory.Error, "_0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveVa_1446", "'{0}' resolves to a type-only declaration and must be imported using a type-only import when 'preserveValueImports' and 'isolatedModules' are both enabled."), + _0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_isolatedModules_is_enabled: diag(1448, ts.DiagnosticCategory.Error, "_0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_isol_1448", "'{0}' resolves to a type-only declaration and must be re-exported using a type-only re-export when 'isolatedModules' is enabled."), + Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed: diag(1449, ts.DiagnosticCategory.Message, "Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed_1449", "Preserve unused imported values in the JavaScript output that would otherwise be removed."), + Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments: diag(1450, ts.DiagnosticCategory.Message, "Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments_1450", "Dynamic imports can only accept a module specifier and an optional assertion as arguments"), + Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression: diag(1451, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member__1451", "Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression"), + The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."), + Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."), 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), Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."), + The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."), Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), @@ -8373,7 +8437,6 @@ var ts; Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), - A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), @@ -8404,7 +8467,6 @@ var ts; Property_0_does_not_exist_on_type_1: diag(2339, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_2339", "Property '{0}' does not exist on type '{1}'."), Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), @@ -8422,7 +8484,7 @@ var ts; The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), + The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or__2360", "The left-hand side of an 'in' expression must be a private identifier or of type 'any', 'string', 'number', or 'symbol'."), The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."), The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), @@ -8437,12 +8499,12 @@ var ts; 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_index_signature_for_type_0: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_index_signature_for_type_0_2374", "Duplicate index signature for type '{0}'."), + Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2375, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2375", "Type '{0}' is not assignable to type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."), 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."), + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2379, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_tr_2379", "Argument of type '{0}' is not assignable to parameter of type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."), The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type: diag(2380, ts.DiagnosticCategory.Error, "The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type_2380", "The return type of a 'get' accessor must be assignable to its 'set' accessor type"), - A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."), Overload_signatures_must_all_be_public_private_or_protected: diag(2385, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."), @@ -8461,7 +8523,6 @@ var ts; constructor_cannot_be_used_as_a_parameter_property_name: diag(2398, ts.DiagnosticCategory.Error, "constructor_cannot_be_used_as_a_parameter_property_name_2398", "'constructor' cannot be used as a parameter property name."), Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."), Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."), - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: diag(2401, ts.DiagnosticCategory.Error, "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference."), Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, ts.DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."), Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, ts.DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'."), The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."), @@ -8471,6 +8532,7 @@ 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'."), + Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target: diag(2412, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2412", "Type '{0}' is not assignable to type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the type of the target."), 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}'."), @@ -8509,9 +8571,7 @@ var ts; Enum_0_used_before_its_declaration: diag(2450, ts.DiagnosticCategory.Error, "Enum_0_used_before_its_declaration_2450", "Enum '{0}' used before its declaration."), Cannot_redeclare_block_scoped_variable_0: diag(2451, ts.DiagnosticCategory.Error, "Cannot_redeclare_block_scoped_variable_0_2451", "Cannot redeclare block-scoped variable '{0}'."), An_enum_member_cannot_have_a_numeric_name: diag(2452, ts.DiagnosticCategory.Error, "An_enum_member_cannot_have_a_numeric_name_2452", "An enum member cannot have a numeric name."), - The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: diag(2453, ts.DiagnosticCategory.Error, "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453", "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly."), Variable_0_is_used_before_being_assigned: diag(2454, ts.DiagnosticCategory.Error, "Variable_0_is_used_before_being_assigned_2454", "Variable '{0}' is used before being assigned."), - Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: diag(2455, ts.DiagnosticCategory.Error, "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'."), Type_alias_0_circularly_references_itself: diag(2456, ts.DiagnosticCategory.Error, "Type_alias_0_circularly_references_itself_2456", "Type alias '{0}' circularly references itself."), Type_alias_name_cannot_be_0: diag(2457, ts.DiagnosticCategory.Error, "Type_alias_name_cannot_be_0_2457", "Type alias name cannot be '{0}'."), An_AMD_module_cannot_have_multiple_name_assignments: diag(2458, ts.DiagnosticCategory.Error, "An_AMD_module_cannot_have_multiple_name_assignments_2458", "An AMD module cannot have multiple name assignments."), @@ -8526,8 +8586,6 @@ var ts; A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type: diag(2467, ts.DiagnosticCategory.Error, "A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type_2467", "A computed property name cannot reference a type parameter from its containing type."), Cannot_find_global_value_0: diag(2468, ts.DiagnosticCategory.Error, "Cannot_find_global_value_0_2468", "Cannot find global value '{0}'."), The_0_operator_cannot_be_applied_to_type_symbol: diag(2469, ts.DiagnosticCategory.Error, "The_0_operator_cannot_be_applied_to_type_symbol_2469", "The '{0}' operator cannot be applied to type 'symbol'."), - Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object: diag(2470, ts.DiagnosticCategory.Error, "Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object_2470", "'Symbol' reference does not refer to the global Symbol constructor object."), - A_computed_property_name_of_the_form_0_must_be_of_type_symbol: diag(2471, ts.DiagnosticCategory.Error, "A_computed_property_name_of_the_form_0_must_be_of_type_symbol_2471", "A computed property name of the form '{0}' must be of type 'symbol'."), Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher: diag(2472, ts.DiagnosticCategory.Error, "Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher_2472", "Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher."), Enum_declarations_must_all_be_const_or_non_const: diag(2473, ts.DiagnosticCategory.Error, "Enum_declarations_must_all_be_const_or_non_const_2473", "Enum declarations must all be const or non-const."), const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values: diag(2474, ts.DiagnosticCategory.Error, "const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values_2474", "const enum member initializers can only contain literal values and other computed enum values."), @@ -8535,7 +8593,6 @@ var ts; A_const_enum_member_can_only_be_accessed_using_a_string_literal: diag(2476, ts.DiagnosticCategory.Error, "A_const_enum_member_can_only_be_accessed_using_a_string_literal_2476", "A const enum member can only be accessed using a string literal."), const_enum_member_initializer_was_evaluated_to_a_non_finite_value: diag(2477, ts.DiagnosticCategory.Error, "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477", "'const' enum member initializer was evaluated to a non-finite value."), const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: diag(2478, ts.DiagnosticCategory.Error, "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478", "'const' enum member initializer was evaluated to disallowed value 'NaN'."), - Property_0_does_not_exist_on_const_enum_1: diag(2479, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_const_enum_1_2479", "Property '{0}' does not exist on 'const' enum '{1}'."), let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: diag(2480, ts.DiagnosticCategory.Error, "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", "'let' is not allowed to be used as a name in 'let' or 'const' declarations."), Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1: diag(2481, ts.DiagnosticCategory.Error, "Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1_2481", "Cannot initialize outer scoped variable '{0}' in the same scope as block scoped declaration '{1}'."), The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation: diag(2483, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation_2483", "The left-hand side of a 'for...of' statement cannot use a type annotation."), @@ -8567,14 +8624,12 @@ var ts; Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."), Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."), Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."), - Classes_containing_abstract_methods_must_be_marked_abstract: diag(2514, ts.DiagnosticCategory.Error, "Classes_containing_abstract_methods_must_be_marked_abstract_2514", "Classes containing abstract methods must be marked abstract."), Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."), All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."), Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."), A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: diag(2518, ts.DiagnosticCategory.Error, "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", "A 'this'-based type guard is not compatible with a parameter-based type guard."), An_async_iterator_must_have_a_next_method: diag(2519, ts.DiagnosticCategory.Error, "An_async_iterator_must_have_a_next_method_2519", "An async iterator must have a 'next()' method."), Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: diag(2520, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions."), - Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: diag(2521, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", "Expression resolves to variable declaration '{0}' that compiler uses to support async functions."), The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: diag(2522, ts.DiagnosticCategory.Error, "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522", "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method."), yield_expressions_cannot_be_used_in_a_parameter_initializer: diag(2523, ts.DiagnosticCategory.Error, "yield_expressions_cannot_be_used_in_a_parameter_initializer_2523", "'yield' expressions cannot be used in a parameter initializer."), await_expressions_cannot_be_used_in_a_parameter_initializer: diag(2524, ts.DiagnosticCategory.Error, "await_expressions_cannot_be_used_in_a_parameter_initializer_2524", "'await' expressions cannot be used in a parameter initializer."), @@ -8594,7 +8649,6 @@ var ts; Type_0_cannot_be_used_as_an_index_type: diag(2538, ts.DiagnosticCategory.Error, "Type_0_cannot_be_used_as_an_index_type_2538", "Type '{0}' cannot be used as an index type."), Cannot_assign_to_0_because_it_is_not_a_variable: diag(2539, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_not_a_variable_2539", "Cannot assign to '{0}' because it is not a variable."), Cannot_assign_to_0_because_it_is_a_read_only_property: diag(2540, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_read_only_property_2540", "Cannot assign to '{0}' because it is a read-only property."), - The_target_of_an_assignment_must_be_a_variable_or_a_property_access: diag(2541, ts.DiagnosticCategory.Error, "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541", "The target of an assignment must be a variable or a property access."), Index_signature_in_type_0_only_permits_reading: diag(2542, ts.DiagnosticCategory.Error, "Index_signature_in_type_0_only_permits_reading_2542", "Index signature in type '{0}' only permits reading."), Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: diag(2543, ts.DiagnosticCategory.Error, "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference."), Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: diag(2544, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference."), @@ -8623,8 +8677,6 @@ var ts; 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."), A_rest_element_type_must_be_an_array_type: diag(2574, ts.DiagnosticCategory.Error, "A_rest_element_type_must_be_an_array_type_2574", "A rest element type must be an array type."), No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, ts.DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."), Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead: diag(2576, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576", "Property '{0}' does not exist on type '{1}'. Did you mean to access the static member '{2}' instead?"), @@ -8636,8 +8688,6 @@ var ts; Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_1_or_later: diag(2583, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2583", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{1}' or later."), Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom: diag(2584, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2584", "Cannot find name '{0}'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'."), _0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later: diag(2585, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_2585", "'{0}' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the 'lib' compiler option to es2015 or later."), - Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."), - JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."), Cannot_assign_to_0_because_it_is_a_constant: diag(2588, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_constant_2588", "Cannot assign to '{0}' because it is a constant."), Type_instantiation_is_excessively_deep_and_possibly_infinite: diag(2589, ts.DiagnosticCategory.Error, "Type_instantiation_is_excessively_deep_and_possibly_infinite_2589", "Type instantiation is excessively deep and possibly infinite."), Expression_produces_a_union_type_that_is_too_complex_to_represent: diag(2590, ts.DiagnosticCategory.Error, "Expression_produces_a_union_type_that_is_too_complex_to_represent_2590", "Expression produces a union type that is too complex to represent."), @@ -8649,12 +8699,9 @@ var ts; _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."), _0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import: diag(2597, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import_2597", "'{0}' can only be imported by using a 'require' call or by using a default import."), _0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2598, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using__2598", "'{0}' can only be imported by using a 'require' call or by turning on the 'esModuleInterop' flag and using a default import."), - JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), - The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), Property_0_in_type_1_is_not_assignable_to_type_2: diag(2603, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_type_2_2603", "Property '{0}' in type '{1}' is not assignable to type '{2}'."), JSX_element_type_0_does_not_have_any_construct_or_call_signatures: diag(2604, ts.DiagnosticCategory.Error, "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", "JSX element type '{0}' does not have any construct or call signatures."), - JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: diag(2605, ts.DiagnosticCategory.Error, "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", "JSX element type '{0}' is not a constructor function for JSX elements."), Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: diag(2606, ts.DiagnosticCategory.Error, "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", "Property '{0}' of JSX spread attribute is not assignable to target property."), JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), @@ -8687,8 +8734,6 @@ var ts; 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."), Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: diag(2653, ts.DiagnosticCategory.Error, "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'."), - Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: diag(2654, ts.DiagnosticCategory.Error, "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition."), - Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: diag(2656, ts.DiagnosticCategory.Error, "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition."), JSX_expressions_must_have_one_parent_element: diag(2657, ts.DiagnosticCategory.Error, "JSX_expressions_must_have_one_parent_element_2657", "JSX expressions must have one parent element."), Type_0_provides_no_match_for_the_signature_1: diag(2658, ts.DiagnosticCategory.Error, "Type_0_provides_no_match_for_the_signature_1_2658", "Type '{0}' provides no match for the signature '{1}'."), super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: diag(2659, ts.DiagnosticCategory.Error, "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher."), @@ -8714,7 +8759,6 @@ var ts; A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void: diag(2679, ts.DiagnosticCategory.Error, "A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void_2679", "A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'."), A_0_parameter_must_be_the_first_parameter: diag(2680, ts.DiagnosticCategory.Error, "A_0_parameter_must_be_the_first_parameter_2680", "A '{0}' parameter must be the first parameter."), A_constructor_cannot_have_a_this_parameter: diag(2681, ts.DiagnosticCategory.Error, "A_constructor_cannot_have_a_this_parameter_2681", "A constructor cannot have a 'this' parameter."), - get_and_set_accessor_must_have_the_same_this_type: diag(2682, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_this_type_2682", "'get' and 'set' accessor must have the same 'this' type."), this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: diag(2683, ts.DiagnosticCategory.Error, "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", "'this' implicitly has type 'any' because it does not have a type annotation."), The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: diag(2684, ts.DiagnosticCategory.Error, "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'."), The_this_types_of_each_signature_are_incompatible: diag(2685, ts.DiagnosticCategory.Error, "The_this_types_of_each_signature_are_incompatible_2685", "The 'this' types of each signature are incompatible."), @@ -8852,6 +8896,12 @@ var ts; 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}'."), + Type_0_is_not_assignable_to_type_1_Did_you_mean_2: diag(2820, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_Did_you_mean_2_2820", "Type '{0}' is not assignable to type '{1}'. Did you mean '{2}'?"), + Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext'."), + Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."), + Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."), + Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{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}'."), @@ -8953,6 +9003,12 @@ var ts; 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."), + This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0: diag(4119, ts.DiagnosticCategory.Error, "This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_4119", "This member must have a JSDoc comment with an '@override' tag because it overrides a member in the base class '{0}'."), + This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0: diag(4120, ts.DiagnosticCategory.Error, "This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_4120", "This parameter property must have a JSDoc comment with an '@override' tag because it overrides a member in the base class '{0}'."), + This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class: diag(4121, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_4121", "This member cannot have a JSDoc comment with an '@override' tag because its containing class '{0}' does not extend another class."), + This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."), + This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"), + Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), 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}'."), @@ -9008,10 +9064,10 @@ var ts; The_root_value_of_a_0_file_must_be_an_object: diag(5092, ts.DiagnosticCategory.Error, "The_root_value_of_a_0_file_must_be_an_object_5092", "The root value of a '{0}' file must be an object."), Compiler_option_0_may_only_be_used_with_build: diag(5093, ts.DiagnosticCategory.Error, "Compiler_option_0_may_only_be_used_with_build_5093", "Compiler option '--{0}' may only be used with '--build'."), Compiler_option_0_may_not_be_used_with_build: diag(5094, ts.DiagnosticCategory.Error, "Compiler_option_0_may_not_be_used_with_build_5094", "Compiler option '--{0}' may not be used with '--build'."), + Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later: diag(5095, ts.DiagnosticCategory.Error, "Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later_5095", "Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later."), 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(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."), @@ -9049,7 +9105,6 @@ var ts; Unterminated_quoted_string_in_response_file_0: diag(6045, ts.DiagnosticCategory.Error, "Unterminated_quoted_string_in_response_file_0_6045", "Unterminated quoted string in response file '{0}'."), Argument_for_0_option_must_be_Colon_1: diag(6046, ts.DiagnosticCategory.Error, "Argument_for_0_option_must_be_Colon_1_6046", "Argument for '{0}' option must be: {1}."), Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1: diag(6048, ts.DiagnosticCategory.Error, "Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1_6048", "Locale must be of the form or -. For example '{0}' or '{1}'."), - Unsupported_locale_0: diag(6049, ts.DiagnosticCategory.Error, "Unsupported_locale_0_6049", "Unsupported locale '{0}'."), Unable_to_open_file_0: diag(6050, ts.DiagnosticCategory.Error, "Unable_to_open_file_0_6050", "Unable to open file '{0}'."), Corrupted_locale_file_0: diag(6051, ts.DiagnosticCategory.Error, "Corrupted_locale_file_0_6051", "Corrupted locale file {0}."), Raise_error_on_expressions_and_declarations_with_an_implied_any_type: diag(6052, ts.DiagnosticCategory.Message, "Raise_error_on_expressions_and_declarations_with_an_implied_any_type_6052", "Raise error on expressions and declarations with an implied 'any' type."), @@ -9064,7 +9119,6 @@ var ts; Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line: diag(6064, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_null_on_command_line_6064", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'null' on command line."), Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."), Enables_experimental_support_for_emitting_type_metadata_for_decorators: diag(6066, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", "Enables experimental support for emitting type metadata for decorators."), - Enables_experimental_support_for_ES7_async_functions: diag(6068, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_async_functions_6068", "Enables experimental support for ES7 async functions."), Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6: diag(6069, ts.DiagnosticCategory.Message, "Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6_6069", "Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6)."), Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: diag(6070, ts.DiagnosticCategory.Message, "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", "Initializes a TypeScript project and creates a tsconfig.json file."), Successfully_created_a_tsconfig_json_file: diag(6071, ts.DiagnosticCategory.Message, "Successfully_created_a_tsconfig_json_file_6071", "Successfully created a tsconfig.json file."), @@ -9099,7 +9153,6 @@ var ts; package_json_does_not_have_a_0_field: diag(6100, ts.DiagnosticCategory.Message, "package_json_does_not_have_a_0_field_6100", "'package.json' does not have a '{0}' field."), package_json_has_0_field_1_that_references_2: diag(6101, ts.DiagnosticCategory.Message, "package_json_has_0_field_1_that_references_2_6101", "'package.json' has '{0}' field '{1}' that references '{2}'."), Allow_javascript_files_to_be_compiled: diag(6102, ts.DiagnosticCategory.Message, "Allow_javascript_files_to_be_compiled_6102", "Allow javascript files to be compiled."), - Option_0_should_have_array_of_strings_as_a_value: diag(6103, ts.DiagnosticCategory.Error, "Option_0_should_have_array_of_strings_as_a_value_6103", "Option '{0}' should have array of strings as a value."), Checking_if_0_is_the_longest_matching_prefix_for_1_2: diag(6104, ts.DiagnosticCategory.Message, "Checking_if_0_is_the_longest_matching_prefix_for_1_2_6104", "Checking if '{0}' is the longest matching prefix for '{1}' - '{2}'."), Expected_type_of_0_field_in_package_json_to_be_1_got_2: diag(6105, ts.DiagnosticCategory.Message, "Expected_type_of_0_field_in_package_json_to_be_1_got_2_6105", "Expected type of '{0}' field in 'package.json' to be '{1}', got '{2}'."), baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1: diag(6106, ts.DiagnosticCategory.Message, "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106", "'baseUrl' option is set to '{0}', using this value to resolve non-relative module name '{1}'."), @@ -9113,8 +9166,6 @@ var ts; Unknown_option_excludes_Did_you_mean_exclude: diag(6114, ts.DiagnosticCategory.Error, "Unknown_option_excludes_Did_you_mean_exclude_6114", "Unknown option 'excludes'. Did you mean 'exclude'?"), Raise_error_on_this_expressions_with_an_implied_any_type: diag(6115, ts.DiagnosticCategory.Message, "Raise_error_on_this_expressions_with_an_implied_any_type_6115", "Raise error on 'this' expressions with an implied 'any' type."), Resolving_type_reference_directive_0_containing_file_1_root_directory_2: diag(6116, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_root_directory_2_6116", "======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========"), - Resolving_using_primary_search_paths: diag(6117, ts.DiagnosticCategory.Message, "Resolving_using_primary_search_paths_6117", "Resolving using primary search paths..."), - Resolving_from_node_modules_folder: diag(6118, ts.DiagnosticCategory.Message, "Resolving_from_node_modules_folder_6118", "Resolving from node_modules folder..."), Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: diag(6119, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119", "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========"), Type_reference_directive_0_was_not_resolved: diag(6120, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_not_resolved_6120", "======== Type reference directive '{0}' was not resolved. ========"), Resolving_with_primary_search_path_0: diag(6121, ts.DiagnosticCategory.Message, "Resolving_with_primary_search_path_0_6121", "Resolving with primary search path '{0}'."), @@ -9158,7 +9209,6 @@ 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(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'."), @@ -9242,7 +9292,14 @@ var ts; 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"), + _0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file: diag(6258, ts.DiagnosticCategory.Error, "_0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file_6258", "'{0}' should be set inside the 'compilerOptions' object of the config json file"), + Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve: diag(6270, ts.DiagnosticCategory.Message, "Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve_6270", "Directory '{0}' has no containing package.json scope. Imports will not resolve."), + Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6271, ts.DiagnosticCategory.Message, "Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6271", "Import specifier '{0}' does not exist in package.json scope at path '{1}'."), + Invalid_import_specifier_0_has_no_possible_resolutions: diag(6272, ts.DiagnosticCategory.Message, "Invalid_import_specifier_0_has_no_possible_resolutions_6272", "Invalid import specifier '{0}' has no possible resolutions."), + package_json_scope_0_has_no_imports_defined: diag(6273, ts.DiagnosticCategory.Message, "package_json_scope_0_has_no_imports_defined_6273", "package.json scope '{0}' has no imports defined."), + package_json_scope_0_explicitly_maps_specifier_1_to_null: diag(6274, ts.DiagnosticCategory.Message, "package_json_scope_0_explicitly_maps_specifier_1_to_null_6274", "package.json scope '{0}' explicitly maps specifier '{1}' to null."), + package_json_scope_0_has_invalid_type_for_target_of_specifier_1: diag(6275, ts.DiagnosticCategory.Message, "package_json_scope_0_has_invalid_type_for_target_of_specifier_1_6275", "package.json scope '{0}' has invalid type for target of specifier '{1}'"), + Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1: diag(6276, ts.DiagnosticCategory.Message, "Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1_6276", "Export specifier '{0}' does not exist in package.json scope at path '{1}'."), 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."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), @@ -9261,7 +9318,6 @@ var ts; A_non_dry_build_would_build_project_0: diag(6357, ts.DiagnosticCategory.Message, "A_non_dry_build_would_build_project_0_6357", "A non-dry build would build project '{0}'"), Building_project_0: diag(6358, ts.DiagnosticCategory.Message, "Building_project_0_6358", "Building project '{0}'..."), Updating_output_timestamps_of_project_0: diag(6359, ts.DiagnosticCategory.Message, "Updating_output_timestamps_of_project_0_6359", "Updating output timestamps of project '{0}'..."), - delete_this_Project_0_is_up_to_date_because_it_was_previously_built: diag(6360, ts.DiagnosticCategory.Message, "delete_this_Project_0_is_up_to_date_because_it_was_previously_built_6360", "delete this - Project '{0}' is up to date because it was previously built"), Project_0_is_up_to_date: diag(6361, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_6361", "Project '{0}' is up to date"), Skipping_build_of_project_0_because_its_dependency_1_has_errors: diag(6362, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_has_errors_6362", "Skipping build of project '{0}' because its dependency '{1}' has errors"), 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"), @@ -9326,6 +9382,7 @@ var ts; 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."), + 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."), 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"), @@ -9357,6 +9414,7 @@ var ts; 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_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_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."), @@ -9449,6 +9507,7 @@ var ts; 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."), + true_for_ES2022_and_above_including_ESNext: diag(6930, ts.DiagnosticCategory.Message, "true_for_ES2022_and_above_including_ESNext_6930", "`true` for ES2022 and above, including ESNext."), 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."), @@ -9499,6 +9558,11 @@ var ts; _0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type: diag(7055, ts.DiagnosticCategory.Error, "_0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type_7055", "'{0}', which lacks return-type annotation, implicitly has an '{1}' yield type."), The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed: diag(7056, ts.DiagnosticCategory.Error, "The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_ty_7056", "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."), yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation: diag(7057, ts.DiagnosticCategory.Error, "yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_t_7057", "'yield' expression implicitly results in an 'any' type because its containing generator lacks a return-type annotation."), + If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_declare_module_1: diag(7058, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058", "If the '{0}' package actually exposes this module, try adding a new declaration (.d.ts) file containing `declare module '{1}';`"), + This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."), + This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."), + A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."), + JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."), You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."), You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."), import_can_only_be_used_in_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."), @@ -9531,15 +9595,11 @@ var ts; Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, ts.DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."), A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, ts.DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."), The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."), - Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), - class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), - Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), - JSX_attribute_expected: diag(17003, ts.DiagnosticCategory.Error, "JSX_attribute_expected_17003", "JSX attribute expected."), Cannot_use_JSX_unless_the_jsx_flag_is_provided: diag(17004, ts.DiagnosticCategory.Error, "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", "Cannot use JSX unless the '--jsx' flag is provided."), A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: diag(17005, ts.DiagnosticCategory.Error, "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", "A constructor cannot contain a 'super' call when its class extends 'null'."), An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: diag(17006, ts.DiagnosticCategory.Error, "An_unary_expression_with_the_0_operator_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_ex_17006", "An unary expression with the '{0}' operator is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses."), @@ -9556,10 +9616,9 @@ var ts; An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments: diag(17017, ts.DiagnosticCategory.Error, "An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments_17017", "An @jsxFrag pragma is required when using an @jsx pragma with JSX fragments."), Unknown_type_acquisition_option_0_Did_you_mean_1: diag(17018, ts.DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_Did_you_mean_1_17018", "Unknown type acquisition option '{0}'. Did you mean '{1}'?"), Circularity_detected_while_resolving_configuration_Colon_0: diag(18000, ts.DiagnosticCategory.Error, "Circularity_detected_while_resolving_configuration_Colon_0_18000", "Circularity detected while resolving configuration: {0}"), - A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: diag(18001, ts.DiagnosticCategory.Error, "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", "A path in an 'extends' option must be relative or rooted, but '{0}' is not."), The_files_list_in_config_file_0_is_empty: diag(18002, ts.DiagnosticCategory.Error, "The_files_list_in_config_file_0_is_empty_18002", "The 'files' list in config file '{0}' is empty."), No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: diag(18003, ts.DiagnosticCategory.Error, "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'."), - File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module: diag(80001, ts.DiagnosticCategory.Suggestion, "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module_80001", "File is a CommonJS module; it may be converted to an ES6 module."), + File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module: diag(80001, ts.DiagnosticCategory.Suggestion, "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001", "File is a CommonJS module; it may be converted to an ES module."), This_constructor_function_may_be_converted_to_a_class_declaration: diag(80002, ts.DiagnosticCategory.Suggestion, "This_constructor_function_may_be_converted_to_a_class_declaration_80002", "This constructor function may be converted to a class declaration."), Import_may_be_converted_to_a_default_import: diag(80003, ts.DiagnosticCategory.Suggestion, "Import_may_be_converted_to_a_default_import_80003", "Import may be converted to a default import."), JSDoc_types_may_be_moved_to_TypeScript_types: diag(80004, ts.DiagnosticCategory.Suggestion, "JSDoc_types_may_be_moved_to_TypeScript_types_80004", "JSDoc types may be moved to TypeScript types."), @@ -9607,8 +9666,8 @@ var ts; Remove_unused_destructuring_declaration: diag(90039, ts.DiagnosticCategory.Message, "Remove_unused_destructuring_declaration_90039", "Remove unused destructuring declaration"), Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"), Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."), + Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), - Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"), Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"), Extract_function: diag(95005, ts.DiagnosticCategory.Message, "Extract_function_95005", "Extract function"), @@ -9616,14 +9675,13 @@ var ts; Extract_to_0_in_enclosing_scope: diag(95007, ts.DiagnosticCategory.Message, "Extract_to_0_in_enclosing_scope_95007", "Extract to {0} in enclosing scope"), Extract_to_0_in_1_scope: diag(95008, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_scope_95008", "Extract to {0} in {1} scope"), Annotate_with_type_from_JSDoc: diag(95009, ts.DiagnosticCategory.Message, "Annotate_with_type_from_JSDoc_95009", "Annotate with type from JSDoc"), - Annotate_with_types_from_JSDoc: diag(95010, ts.DiagnosticCategory.Message, "Annotate_with_types_from_JSDoc_95010", "Annotate with types from JSDoc"), Infer_type_of_0_from_usage: diag(95011, ts.DiagnosticCategory.Message, "Infer_type_of_0_from_usage_95011", "Infer type of '{0}' from usage"), Infer_parameter_types_from_usage: diag(95012, ts.DiagnosticCategory.Message, "Infer_parameter_types_from_usage_95012", "Infer parameter types from usage"), Convert_to_default_import: diag(95013, ts.DiagnosticCategory.Message, "Convert_to_default_import_95013", "Convert to default import"), Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"), Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."), Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."), - Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"), + Convert_to_ES_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES_module_95017", "Convert to ES module"), Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"), Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"), Add_definite_assignment_assertion_to_property_0: diag(95020, ts.DiagnosticCategory.Message, "Add_definite_assignment_assertion_to_property_0_95020", "Add definite assignment assertion to property '{0}'"), @@ -9707,9 +9765,6 @@ var ts; Set_the_module_option_in_your_configuration_file_to_0: diag(95099, ts.DiagnosticCategory.Message, "Set_the_module_option_in_your_configuration_file_to_0_95099", "Set the 'module' option in your configuration file to '{0}'"), Convert_invalid_character_to_its_html_entity_code: diag(95100, ts.DiagnosticCategory.Message, "Convert_invalid_character_to_its_html_entity_code_95100", "Convert invalid character to its html entity code"), Convert_all_invalid_characters_to_HTML_entity_code: diag(95101, ts.DiagnosticCategory.Message, "Convert_all_invalid_characters_to_HTML_entity_code_95101", "Convert all invalid characters to HTML entity code"), - Add_class_tag: diag(95102, ts.DiagnosticCategory.Message, "Add_class_tag_95102", "Add '@class' tag"), - Add_this_tag: diag(95103, ts.DiagnosticCategory.Message, "Add_this_tag_95103", "Add '@this' tag"), - Add_this_parameter: diag(95104, ts.DiagnosticCategory.Message, "Add_this_parameter_95104", "Add 'this' parameter."), Convert_function_expression_0_to_arrow_function: diag(95105, ts.DiagnosticCategory.Message, "Convert_function_expression_0_to_arrow_function_95105", "Convert function expression '{0}' to arrow function"), Convert_function_declaration_0_to_arrow_function: diag(95106, ts.DiagnosticCategory.Message, "Convert_function_declaration_0_to_arrow_function_95106", "Convert function declaration '{0}' to arrow function"), Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"), @@ -9774,6 +9829,7 @@ var ts; 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"), + Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"), 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?"), @@ -9822,11 +9878,12 @@ var ts; /** @internal */ ts.textToKeywordObj = (_a = { abstract: 126 /* AbstractKeyword */, - any: 129 /* AnyKeyword */, + any: 130 /* AnyKeyword */, as: 127 /* AsKeyword */, asserts: 128 /* AssertsKeyword */, - bigint: 156 /* BigIntKeyword */, - boolean: 132 /* BooleanKeyword */, + assert: 129 /* AssertKeyword */, + bigint: 157 /* BigIntKeyword */, + boolean: 133 /* BooleanKeyword */, break: 81 /* BreakKeyword */, case: 82 /* CaseKeyword */, catch: 83 /* CatchKeyword */, @@ -9834,9 +9891,9 @@ var ts; continue: 86 /* ContinueKeyword */, const: 85 /* ConstKeyword */ }, - _a["" + "constructor"] = 133 /* ConstructorKeyword */, + _a["" + "constructor"] = 134 /* ConstructorKeyword */, _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 134 /* DeclareKeyword */, + _a.declare = 135 /* DeclareKeyword */, _a.default = 88 /* DefaultKeyword */, _a.delete = 89 /* DeleteKeyword */, _a.do = 90 /* DoKeyword */, @@ -9847,59 +9904,59 @@ var ts; _a.false = 95 /* FalseKeyword */, _a.finally = 96 /* FinallyKeyword */, _a.for = 97 /* ForKeyword */, - _a.from = 154 /* FromKeyword */, + _a.from = 155 /* FromKeyword */, _a.function = 98 /* FunctionKeyword */, - _a.get = 135 /* GetKeyword */, + _a.get = 136 /* GetKeyword */, _a.if = 99 /* IfKeyword */, _a.implements = 117 /* ImplementsKeyword */, _a.import = 100 /* ImportKeyword */, _a.in = 101 /* InKeyword */, - _a.infer = 136 /* InferKeyword */, + _a.infer = 137 /* InferKeyword */, _a.instanceof = 102 /* InstanceOfKeyword */, _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 137 /* IntrinsicKeyword */, - _a.is = 138 /* IsKeyword */, - _a.keyof = 139 /* KeyOfKeyword */, + _a.intrinsic = 138 /* IntrinsicKeyword */, + _a.is = 139 /* IsKeyword */, + _a.keyof = 140 /* KeyOfKeyword */, _a.let = 119 /* LetKeyword */, - _a.module = 140 /* ModuleKeyword */, - _a.namespace = 141 /* NamespaceKeyword */, - _a.never = 142 /* NeverKeyword */, + _a.module = 141 /* ModuleKeyword */, + _a.namespace = 142 /* NamespaceKeyword */, + _a.never = 143 /* NeverKeyword */, _a.new = 103 /* NewKeyword */, _a.null = 104 /* NullKeyword */, - _a.number = 145 /* NumberKeyword */, - _a.object = 146 /* ObjectKeyword */, + _a.number = 146 /* NumberKeyword */, + _a.object = 147 /* 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.override = 158 /* OverrideKeyword */, + _a.readonly = 144 /* ReadonlyKeyword */, + _a.require = 145 /* RequireKeyword */, + _a.global = 156 /* GlobalKeyword */, _a.return = 105 /* ReturnKeyword */, - _a.set = 147 /* SetKeyword */, + _a.set = 148 /* SetKeyword */, _a.static = 124 /* StaticKeyword */, - _a.string = 148 /* StringKeyword */, + _a.string = 149 /* StringKeyword */, _a.super = 106 /* SuperKeyword */, _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 149 /* SymbolKeyword */, + _a.symbol = 150 /* SymbolKeyword */, _a.this = 108 /* ThisKeyword */, _a.throw = 109 /* ThrowKeyword */, _a.true = 110 /* TrueKeyword */, _a.try = 111 /* TryKeyword */, - _a.type = 150 /* TypeKeyword */, + _a.type = 151 /* TypeKeyword */, _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 151 /* UndefinedKeyword */, - _a.unique = 152 /* UniqueKeyword */, - _a.unknown = 153 /* UnknownKeyword */, + _a.undefined = 152 /* UndefinedKeyword */, + _a.unique = 153 /* UniqueKeyword */, + _a.unknown = 154 /* 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.async = 131 /* AsyncKeyword */, + _a.await = 132 /* AwaitKeyword */, + _a.of = 159 /* OfKeyword */, _a); 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 */ }))); @@ -12113,7 +12170,7 @@ var ts; } ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { - switch (options.target) { + switch (ts.getEmitScriptTarget(options)) { case 99 /* ESNext */: return "lib.esnext.full.d.ts"; case 8 /* ES2021 */: @@ -12336,9 +12393,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 161 /* TypeParameter */) { + if (d && d.kind === 162 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 256 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 257 /* InterfaceDeclaration */) { return current; } } @@ -12346,7 +12403,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 169 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 170 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12376,14 +12433,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 252 /* VariableDeclaration */) { + if (node.kind === 253 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 253 /* VariableDeclarationList */) { + if (node && node.kind === 254 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 235 /* VariableStatement */) { + if (node && node.kind === 236 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12556,30 +12613,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 219 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 220 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return expr.name; - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 210 /* ParenthesizedExpression */: { + case 211 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 248 /* LabeledStatement */: { + case 249 /* LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12616,16 +12673,16 @@ var ts; switch (declaration.kind) { case 79 /* Identifier */: return declaration; - case 342 /* JSDocPropertyTag */: - case 335 /* JSDocParameterTag */: { + case 345 /* JSDocPropertyTag */: + case 338 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 159 /* QualifiedName */) { + if (name.kind === 160 /* QualifiedName */) { return name.right; } break; } - case 206 /* CallExpression */: - case 219 /* BinaryExpression */: { + case 207 /* CallExpression */: + case 220 /* BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: @@ -12641,15 +12698,15 @@ var ts; return undefined; } } - case 340 /* JSDocTypedefTag */: + case 343 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 334 /* JSDocEnumTag */: + case 337 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 269 /* ExportAssignment */: { + case 270 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -12944,7 +13001,7 @@ var ts; return typeof comment === "string" ? comment : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { // TODO: Other kinds here - return c.kind === 316 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; + return c.kind === 319 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; @@ -12957,7 +13014,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 315 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 318 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12989,7 +13046,7 @@ var ts; ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 171 /* SetAccessor */ || node.kind === 170 /* GetAccessor */; + return node.kind === 172 /* SetAccessor */ || node.kind === 171 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { @@ -13007,10 +13064,10 @@ var ts; function isOptionalChain(node) { var kind = node.kind; return !!(node.flags & 32 /* OptionalChain */) && - (kind === 204 /* PropertyAccessExpression */ - || kind === 205 /* ElementAccessExpression */ - || kind === 206 /* CallExpression */ - || kind === 228 /* NonNullExpression */); + (kind === 205 /* PropertyAccessExpression */ + || kind === 206 /* ElementAccessExpression */ + || kind === 207 /* CallExpression */ + || kind === 229 /* NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13045,7 +13102,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 219 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 220 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13062,17 +13119,17 @@ var ts; } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 244 /* BreakStatement */ || node.kind === 243 /* ContinueStatement */; + return node.kind === 245 /* BreakStatement */ || node.kind === 244 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 272 /* NamespaceExport */ || node.kind === 271 /* NamedExports */; + return node.kind === 273 /* NamespaceExport */ || node.kind === 272 /* NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 297 /* UnparsedText */: - case 298 /* UnparsedInternalText */: + case 300 /* UnparsedText */: + case 301 /* UnparsedInternalText */: return true; default: return false; @@ -13081,12 +13138,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 295 /* UnparsedPrologue */ || - node.kind === 299 /* UnparsedSyntheticReference */; + node.kind === 298 /* UnparsedPrologue */ || + node.kind === 302 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 342 /* JSDocPropertyTag */ || node.kind === 335 /* JSDocParameterTag */; + return node.kind === 345 /* JSDocPropertyTag */ || node.kind === 338 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13102,7 +13159,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 159 /* FirstNode */; + return kind >= 160 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13111,7 +13168,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 158 /* LastToken */; + return kind >= 0 /* FirstToken */ && kind <= 159 /* LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13161,19 +13218,23 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 268 /* ImportSpecifier */: - case 273 /* ExportSpecifier */: - return node.parent.parent.isTypeOnly; - case 266 /* NamespaceImport */: + case 269 /* ImportSpecifier */: + case 274 /* ExportSpecifier */: + return node.isTypeOnly || node.parent.parent.isTypeOnly; + case 267 /* NamespaceImport */: return node.parent.isTypeOnly; - case 265 /* ImportClause */: - case 263 /* ImportEqualsDeclaration */: + case 266 /* ImportClause */: + case 264 /* ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; } } ts.isTypeOnlyImportOrExportDeclaration = isTypeOnlyImportOrExportDeclaration; + function isAssertionKey(node) { + return ts.isStringLiteral(node) || ts.isIdentifier(node); + } + ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); } @@ -13200,17 +13261,17 @@ var ts; function isModifierKind(token) { switch (token) { case 126 /* AbstractKeyword */: - case 130 /* AsyncKeyword */: + case 131 /* AsyncKeyword */: case 85 /* ConstKeyword */: - case 134 /* DeclareKeyword */: + case 135 /* DeclareKeyword */: case 88 /* DefaultKeyword */: case 93 /* ExportKeyword */: case 123 /* PublicKeyword */: case 121 /* PrivateKeyword */: case 122 /* ProtectedKeyword */: - case 143 /* ReadonlyKeyword */: + case 144 /* ReadonlyKeyword */: case 124 /* StaticKeyword */: - case 157 /* OverrideKeyword */: + case 158 /* OverrideKeyword */: return true; } return false; @@ -13223,7 +13284,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 157 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 158 /* OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13232,7 +13293,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 159 /* QualifiedName */ + return kind === 160 /* QualifiedName */ || kind === 79 /* Identifier */; } ts.isEntityName = isEntityName; @@ -13242,14 +13303,14 @@ var ts; || kind === 80 /* PrivateIdentifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 160 /* ComputedPropertyName */; + || kind === 161 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 79 /* Identifier */ - || kind === 199 /* ObjectBindingPattern */ - || kind === 200 /* ArrayBindingPattern */; + || kind === 200 /* ObjectBindingPattern */ + || kind === 201 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13274,13 +13335,13 @@ var ts; ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 254 /* FunctionDeclaration */: - case 167 /* MethodDeclaration */: - case 169 /* Constructor */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 255 /* FunctionDeclaration */: + case 168 /* MethodDeclaration */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return true; default: return false; @@ -13289,14 +13350,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 166 /* MethodSignature */: - case 172 /* CallSignature */: - case 318 /* JSDocSignature */: - case 173 /* ConstructSignature */: - case 174 /* IndexSignature */: - case 177 /* FunctionType */: - case 312 /* JSDocFunctionType */: - case 178 /* ConstructorType */: + case 167 /* MethodSignature */: + case 173 /* CallSignature */: + case 321 /* JSDocSignature */: + case 174 /* ConstructSignature */: + case 175 /* IndexSignature */: + case 178 /* FunctionType */: + case 315 /* JSDocFunctionType */: + case 179 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13311,30 +13372,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - 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 */; + return kind === 170 /* Constructor */ + || kind === 166 /* PropertyDeclaration */ + || kind === 168 /* MethodDeclaration */ + || kind === 171 /* GetAccessor */ + || kind === 172 /* SetAccessor */ + || kind === 175 /* IndexSignature */ + || kind === 169 /* ClassStaticBlockDeclaration */ + || kind === 233 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 255 /* ClassDeclaration */ || node.kind === 224 /* ClassExpression */); + return node && (node.kind === 256 /* ClassDeclaration */ || node.kind === 225 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 170 /* GetAccessor */ || node.kind === 171 /* SetAccessor */); + return node && (node.kind === 171 /* GetAccessor */ || node.kind === 172 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return true; default: return false; @@ -13344,11 +13405,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 173 /* ConstructSignature */ - || kind === 172 /* CallSignature */ - || kind === 164 /* PropertySignature */ - || kind === 166 /* MethodSignature */ - || kind === 174 /* IndexSignature */; + return kind === 174 /* ConstructSignature */ + || kind === 173 /* CallSignature */ + || kind === 165 /* PropertySignature */ + || kind === 167 /* MethodSignature */ + || kind === 175 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13357,12 +13418,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 291 /* PropertyAssignment */ - || kind === 292 /* ShorthandPropertyAssignment */ - || kind === 293 /* SpreadAssignment */ - || kind === 167 /* MethodDeclaration */ - || kind === 170 /* GetAccessor */ - || kind === 171 /* SetAccessor */; + return kind === 294 /* PropertyAssignment */ + || kind === 295 /* ShorthandPropertyAssignment */ + || kind === 296 /* SpreadAssignment */ + || kind === 168 /* MethodDeclaration */ + || kind === 171 /* GetAccessor */ + || kind === 172 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13377,8 +13438,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 177 /* FunctionType */: - case 178 /* ConstructorType */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: return true; } return false; @@ -13389,8 +13450,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 200 /* ArrayBindingPattern */ - || kind === 199 /* ObjectBindingPattern */; + return kind === 201 /* ArrayBindingPattern */ + || kind === 200 /* ObjectBindingPattern */; } return false; } @@ -13398,15 +13459,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 202 /* ArrayLiteralExpression */ - || kind === 203 /* ObjectLiteralExpression */; + return kind === 203 /* ArrayLiteralExpression */ + || kind === 204 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 201 /* BindingElement */ - || kind === 225 /* OmittedExpression */; + return kind === 202 /* BindingElement */ + || kind === 226 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13415,9 +13476,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 252 /* VariableDeclaration */: - case 162 /* Parameter */: - case 201 /* BindingElement */: + case 253 /* VariableDeclaration */: + case 163 /* Parameter */: + case 202 /* BindingElement */: return true; } return false; @@ -13438,8 +13499,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 199 /* ObjectBindingPattern */: - case 203 /* ObjectLiteralExpression */: + case 200 /* ObjectBindingPattern */: + case 204 /* ObjectLiteralExpression */: return true; } return false; @@ -13448,10 +13509,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 201 /* BindingElement */: - case 291 /* PropertyAssignment */: // AssignmentProperty - case 292 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 293 /* SpreadAssignment */: // AssignmentRestProperty + case 202 /* BindingElement */: + case 294 /* PropertyAssignment */: // AssignmentProperty + case 295 /* ShorthandPropertyAssignment */: // AssignmentProperty + case 296 /* SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13463,8 +13524,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 200 /* ArrayBindingPattern */: - case 202 /* ArrayLiteralExpression */: + case 201 /* ArrayBindingPattern */: + case 203 /* ArrayLiteralExpression */: return true; } return false; @@ -13473,26 +13534,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 204 /* PropertyAccessExpression */ - || kind === 159 /* QualifiedName */ - || kind === 198 /* ImportType */; + return kind === 205 /* PropertyAccessExpression */ + || kind === 160 /* QualifiedName */ + || kind === 199 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 204 /* PropertyAccessExpression */ - || kind === 159 /* QualifiedName */; + return kind === 205 /* PropertyAccessExpression */ + || kind === 160 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 278 /* JsxOpeningElement */: - case 277 /* JsxSelfClosingElement */: - case 206 /* CallExpression */: - case 207 /* NewExpression */: - case 208 /* TaggedTemplateExpression */: - case 163 /* Decorator */: + case 279 /* JsxOpeningElement */: + case 278 /* JsxSelfClosingElement */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: + case 209 /* TaggedTemplateExpression */: + case 164 /* Decorator */: return true; default: return false; @@ -13500,12 +13561,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 206 /* CallExpression */ || node.kind === 207 /* NewExpression */; + return node.kind === 207 /* CallExpression */ || node.kind === 208 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 221 /* TemplateExpression */ + return kind === 222 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13516,33 +13577,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - 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 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: + case 208 /* NewExpression */: + case 207 /* CallExpression */: + case 277 /* JsxElement */: + case 278 /* JsxSelfClosingElement */: + case 281 /* JsxFragment */: + case 209 /* TaggedTemplateExpression */: + case 203 /* ArrayLiteralExpression */: + case 211 /* ParenthesizedExpression */: + case 204 /* ObjectLiteralExpression */: + case 225 /* ClassExpression */: + case 212 /* FunctionExpression */: case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 221 /* TemplateExpression */: + case 222 /* TemplateExpression */: case 95 /* FalseKeyword */: case 104 /* NullKeyword */: case 108 /* ThisKeyword */: case 110 /* TrueKeyword */: case 106 /* SuperKeyword */: - case 228 /* NonNullExpression */: - case 229 /* MetaProperty */: + case 229 /* NonNullExpression */: + case 230 /* MetaProperty */: case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -13556,13 +13618,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 217 /* PrefixUnaryExpression */: - case 218 /* PostfixUnaryExpression */: - case 213 /* DeleteExpression */: - case 214 /* TypeOfExpression */: - case 215 /* VoidExpression */: - case 216 /* AwaitExpression */: - case 209 /* TypeAssertionExpression */: + case 218 /* PrefixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: + case 214 /* DeleteExpression */: + case 215 /* TypeOfExpression */: + case 216 /* VoidExpression */: + case 217 /* AwaitExpression */: + case 210 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13571,9 +13633,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 218 /* PostfixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: return true; - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: return expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; default: @@ -13592,15 +13654,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - 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 */: + case 221 /* ConditionalExpression */: + case 223 /* YieldExpression */: + case 213 /* ArrowFunction */: + case 220 /* BinaryExpression */: + case 224 /* SpreadElement */: + case 228 /* AsExpression */: + case 226 /* OmittedExpression */: + case 349 /* CommaListExpression */: + case 348 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13608,8 +13670,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 209 /* TypeAssertionExpression */ - || kind === 227 /* AsExpression */; + return kind === 210 /* TypeAssertionExpression */ + || kind === 228 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13620,13 +13682,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 240 /* ForStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: - case 238 /* DoStatement */: - case 239 /* WhileStatement */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: return true; - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13655,7 +13717,7 @@ var ts; ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 241 /* ForInStatement */ || node.kind === 242 /* ForOfStatement */; + return node.kind === 242 /* ForInStatement */ || node.kind === 243 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13679,115 +13741,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 260 /* ModuleBlock */ - || kind === 259 /* ModuleDeclaration */ + return kind === 261 /* ModuleBlock */ + || kind === 260 /* ModuleDeclaration */ || kind === 79 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 260 /* ModuleBlock */ - || kind === 259 /* ModuleDeclaration */; + return kind === 261 /* ModuleBlock */ + || kind === 260 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 79 /* Identifier */ - || kind === 259 /* ModuleDeclaration */; + || kind === 260 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 267 /* NamedImports */ - || kind === 266 /* NamespaceImport */; + return kind === 268 /* NamedImports */ + || kind === 267 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 259 /* ModuleDeclaration */ || node.kind === 258 /* EnumDeclaration */; + return node.kind === 260 /* ModuleDeclaration */ || node.kind === 259 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - 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 */; + return kind === 213 /* ArrowFunction */ + || kind === 202 /* BindingElement */ + || kind === 256 /* ClassDeclaration */ + || kind === 225 /* ClassExpression */ + || kind === 169 /* ClassStaticBlockDeclaration */ + || kind === 170 /* Constructor */ + || kind === 259 /* EnumDeclaration */ + || kind === 297 /* EnumMember */ + || kind === 274 /* ExportSpecifier */ + || kind === 255 /* FunctionDeclaration */ + || kind === 212 /* FunctionExpression */ + || kind === 171 /* GetAccessor */ + || kind === 266 /* ImportClause */ + || kind === 264 /* ImportEqualsDeclaration */ + || kind === 269 /* ImportSpecifier */ + || kind === 257 /* InterfaceDeclaration */ + || kind === 284 /* JsxAttribute */ + || kind === 168 /* MethodDeclaration */ + || kind === 167 /* MethodSignature */ + || kind === 260 /* ModuleDeclaration */ + || kind === 263 /* NamespaceExportDeclaration */ + || kind === 267 /* NamespaceImport */ + || kind === 273 /* NamespaceExport */ + || kind === 163 /* Parameter */ + || kind === 294 /* PropertyAssignment */ + || kind === 166 /* PropertyDeclaration */ + || kind === 165 /* PropertySignature */ + || kind === 172 /* SetAccessor */ + || kind === 295 /* ShorthandPropertyAssignment */ + || kind === 258 /* TypeAliasDeclaration */ + || kind === 162 /* TypeParameter */ + || kind === 253 /* VariableDeclaration */ + || kind === 343 /* JSDocTypedefTag */ + || kind === 336 /* JSDocCallbackTag */ + || kind === 345 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - 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 */; + return kind === 255 /* FunctionDeclaration */ + || kind === 275 /* MissingDeclaration */ + || kind === 256 /* ClassDeclaration */ + || kind === 257 /* InterfaceDeclaration */ + || kind === 258 /* TypeAliasDeclaration */ + || kind === 259 /* EnumDeclaration */ + || kind === 260 /* ModuleDeclaration */ + || kind === 265 /* ImportDeclaration */ + || kind === 264 /* ImportEqualsDeclaration */ + || kind === 271 /* ExportDeclaration */ + || kind === 270 /* ExportAssignment */ + || kind === 263 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - 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 */; + return kind === 245 /* BreakStatement */ + || kind === 244 /* ContinueStatement */ + || kind === 252 /* DebuggerStatement */ + || kind === 239 /* DoStatement */ + || kind === 237 /* ExpressionStatement */ + || kind === 235 /* EmptyStatement */ + || kind === 242 /* ForInStatement */ + || kind === 243 /* ForOfStatement */ + || kind === 241 /* ForStatement */ + || kind === 238 /* IfStatement */ + || kind === 249 /* LabeledStatement */ + || kind === 246 /* ReturnStatement */ + || kind === 248 /* SwitchStatement */ + || kind === 250 /* ThrowStatement */ + || kind === 251 /* TryStatement */ + || kind === 236 /* VariableStatement */ + || kind === 240 /* WhileStatement */ + || kind === 247 /* WithStatement */ + || kind === 347 /* NotEmittedStatement */ + || kind === 351 /* EndOfDeclarationMarker */ + || kind === 350 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 161 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 339 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 162 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 342 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13814,10 +13876,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 233 /* Block */) + if (node.kind !== 234 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 250 /* TryStatement */ || node.parent.kind === 290 /* CatchClause */) { + if (node.parent.kind === 251 /* TryStatement */ || node.parent.kind === 291 /* CatchClause */) { return false; } } @@ -13831,15 +13893,15 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 233 /* Block */; + || kind === 234 /* Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 275 /* ExternalModuleReference */ - || kind === 159 /* QualifiedName */ + return kind === 276 /* ExternalModuleReference */ + || kind === 160 /* QualifiedName */ || kind === 79 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -13849,58 +13911,58 @@ var ts; var kind = node.kind; return kind === 108 /* ThisKeyword */ || kind === 79 /* Identifier */ - || kind === 204 /* PropertyAccessExpression */; + || kind === 205 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 276 /* JsxElement */ - || kind === 286 /* JsxExpression */ - || kind === 277 /* JsxSelfClosingElement */ + return kind === 277 /* JsxElement */ + || kind === 287 /* JsxExpression */ + || kind === 278 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 280 /* JsxFragment */; + || kind === 281 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 283 /* JsxAttribute */ - || kind === 285 /* JsxSpreadAttribute */; + return kind === 284 /* JsxAttribute */ + || kind === 286 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 286 /* JsxExpression */; + || kind === 287 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 278 /* JsxOpeningElement */ - || kind === 277 /* JsxSelfClosingElement */; + return kind === 279 /* JsxOpeningElement */ + || kind === 278 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 287 /* CaseClause */ - || kind === 288 /* DefaultClause */; + return kind === 288 /* CaseClause */ + || kind === 289 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 304 /* FirstJSDocNode */ && node.kind <= 342 /* LastJSDocNode */; + return node.kind >= 307 /* FirstJSDocNode */ && node.kind <= 345 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 315 /* JSDocComment */ - || node.kind === 314 /* JSDocNamepathType */ - || node.kind === 316 /* JSDocText */ + return node.kind === 318 /* JSDocComment */ + || node.kind === 317 /* JSDocNamepathType */ + || node.kind === 319 /* JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -13910,15 +13972,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 322 /* FirstJSDocTagNode */ && node.kind <= 342 /* LastJSDocTagNode */; + return node.kind >= 325 /* FirstJSDocTagNode */ && node.kind <= 345 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 171 /* SetAccessor */; + return node.kind === 172 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 170 /* GetAccessor */; + return node.kind === 171 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -13944,13 +14006,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 252 /* VariableDeclaration */: - case 162 /* Parameter */: - case 201 /* BindingElement */: - case 164 /* PropertySignature */: - case 165 /* PropertyDeclaration */: - case 291 /* PropertyAssignment */: - case 294 /* EnumMember */: + case 253 /* VariableDeclaration */: + case 163 /* Parameter */: + case 202 /* BindingElement */: + case 165 /* PropertySignature */: + case 166 /* PropertyDeclaration */: + case 294 /* PropertyAssignment */: + case 297 /* EnumMember */: return true; default: return false; @@ -13958,12 +14020,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 283 /* JsxAttribute */ || node.kind === 285 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 284 /* JsxAttribute */ || node.kind === 286 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 176 /* TypeReference */ || node.kind === 226 /* ExpressionWithTypeArguments */; + return node.kind === 177 /* TypeReference */ || node.kind === 227 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13996,7 +14058,7 @@ var ts; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 319 /* JSDocLink */ || node.kind === 320 /* JSDocLinkCode */ || node.kind === 321 /* JSDocLinkPlain */; + return node.kind === 322 /* JSDocLink */ || node.kind === 323 /* JSDocLinkCode */ || node.kind === 324 /* JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; // #endregion @@ -14172,22 +14234,22 @@ var ts; return node.end - node.pos; } ts.getFullWidth = getFullWidth; - function getResolvedModule(sourceFile, moduleNameText) { - return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText); + function getResolvedModule(sourceFile, moduleNameText, mode) { + return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode); } ts.getResolvedModule = getResolvedModule; - function setResolvedModule(sourceFile, moduleNameText, resolvedModule) { + function setResolvedModule(sourceFile, moduleNameText, resolvedModule, mode) { if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = new ts.Map(); + sourceFile.resolvedModules = ts.createModeAwareCache(); } - sourceFile.resolvedModules.set(moduleNameText, resolvedModule); + sourceFile.resolvedModules.set(moduleNameText, mode, resolvedModule); } ts.setResolvedModule = setResolvedModule; function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { - sourceFile.resolvedTypeReferenceDirectiveNames = new ts.Map(); + sourceFile.resolvedTypeReferenceDirectiveNames = ts.createModeAwareCache(); } - sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective); + sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, /*mode*/ undefined, resolvedTypeReferenceDirective); } ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective; function projectReferenceIsEqualTo(oldRef, newRef) { @@ -14219,11 +14281,11 @@ var ts; && oldResolution.originalPath === newResolution.originalPath; } ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; - function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { + function hasChangesInResolutions(names, newResolutions, oldResolutions, oldSourceFile, comparer) { ts.Debug.assert(names.length === newResolutions.length); for (var i = 0; i < names.length; i++) { var newResolution = newResolutions[i]; - var oldResolution = oldResolutions && oldResolutions.get(names[i]); + var oldResolution = oldResolutions && oldResolutions.get(names[i], oldSourceFile && ts.getModeForResolutionAtIndex(oldSourceFile, i)); var changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution; @@ -14258,7 +14320,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 300 /* SourceFile */) { + while (node && node.kind !== 303 /* SourceFile */) { node = node.parent; } return node; @@ -14270,11 +14332,11 @@ var ts; ts.getSourceFileOfModule = getSourceFileOfModule; function isStatementWithLocals(node) { switch (node.kind) { - case 233 /* Block */: - case 261 /* CaseBlock */: - case 240 /* ForStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: + case 234 /* Block */: + case 262 /* CaseBlock */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: return true; } return false; @@ -14470,7 +14532,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 === 343 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 346 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -14692,7 +14754,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 252 /* VariableDeclaration */ && node.parent.kind === 290 /* CatchClause */; + return node.kind === 253 /* VariableDeclaration */ && node.parent.kind === 291 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -14724,11 +14786,11 @@ 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 === 259 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 260 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 300 /* SourceFile */ || - node.kind === 259 /* ModuleDeclaration */ || + return node.kind === 303 /* SourceFile */ || + node.kind === 260 /* ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -14745,9 +14807,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 300 /* SourceFile */: + case 303 /* SourceFile */: return ts.isExternalModule(node.parent); - case 260 /* ModuleBlock */: + case 261 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -14758,8 +14820,11 @@ var ts; return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); } ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration; + function isCommonJSContainingModuleKind(kind) { + return kind === ts.ModuleKind.CommonJS || kind === ts.ModuleKind.Node12 || kind === ts.ModuleKind.NodeNext; + } function isEffectiveExternalModule(node, compilerOptions) { - return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); + return ts.isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator); } ts.isEffectiveExternalModule = isEffectiveExternalModule; /** @@ -14801,24 +14866,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - 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 */: + case 303 /* SourceFile */: + case 262 /* CaseBlock */: + case 291 /* CatchClause */: + case 260 /* ModuleDeclaration */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 170 /* Constructor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 166 /* PropertyDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: return true; - case 233 /* Block */: + case 234 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -14828,9 +14893,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 333 /* JSDocCallbackTag */: - case 340 /* JSDocTypedefTag */: - case 318 /* JSDocSignature */: + case 336 /* JSDocCallbackTag */: + case 343 /* JSDocTypedefTag */: + case 321 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -14840,25 +14905,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - 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 */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 167 /* MethodSignature */: + case 175 /* IndexSignature */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: + case 315 /* JSDocFunctionType */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 342 /* JSDocTemplateTag */: + case 255 /* FunctionDeclaration */: + case 168 /* MethodDeclaration */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -14868,8 +14933,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 264 /* ImportDeclaration */: - case 263 /* ImportEqualsDeclaration */: + case 265 /* ImportDeclaration */: + case 264 /* ImportEqualsDeclaration */: return true; default: return false; @@ -14878,15 +14943,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - 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 */: + case 265 /* ImportDeclaration */: + case 264 /* ImportEqualsDeclaration */: + case 236 /* VariableStatement */: + case 256 /* ClassDeclaration */: + case 255 /* FunctionDeclaration */: + case 260 /* ModuleDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 257 /* InterfaceDeclaration */: + case 259 /* EnumDeclaration */: return true; default: return false; @@ -14927,7 +14992,7 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 160 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 161 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { @@ -14939,7 +15004,7 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 160 /* ComputedPropertyName */: + case 161 /* 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"); @@ -14955,16 +15020,16 @@ var ts; case 80 /* PrivateIdentifier */: case 79 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 204 /* PropertyAccessExpression */: + case 205 /* 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 */: + case 309 /* JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15045,7 +15110,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 233 /* Block */) { + if (node.body && node.body.kind === 234 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15059,7 +15124,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 300 /* SourceFile */: + case 303 /* 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 @@ -15068,29 +15133,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 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 */: + case 253 /* VariableDeclaration */: + case 202 /* BindingElement */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: + case 260 /* ModuleDeclaration */: + case 259 /* EnumDeclaration */: + case 297 /* EnumMember */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 258 /* TypeAliasDeclaration */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 267 /* NamespaceImport */: errorNode = node.name; break; - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 287 /* CaseClause */: - case 288 /* DefaultClause */: + case 288 /* CaseClause */: + case 289 /* 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); @@ -15142,11 +15207,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 206 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 207 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 206 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 207 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { @@ -15160,7 +15225,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 236 /* ExpressionStatement */ + return node.kind === 237 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -15188,12 +15253,12 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - 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 */) ? + var commentRanges = (node.kind === 163 /* Parameter */ || + node.kind === 162 /* TypeParameter */ || + node.kind === 212 /* FunctionExpression */ || + node.kind === 213 /* ArrowFunction */ || + node.kind === 211 /* ParenthesizedExpression */ || + node.kind === 253 /* 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 '/**/' @@ -15209,48 +15274,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (175 /* FirstTypeNode */ <= node.kind && node.kind <= 198 /* LastTypeNode */) { + if (176 /* FirstTypeNode */ <= node.kind && node.kind <= 199 /* LastTypeNode */) { return true; } switch (node.kind) { - 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 */: + case 130 /* AnyKeyword */: + case 154 /* UnknownKeyword */: + case 146 /* NumberKeyword */: + case 157 /* BigIntKeyword */: + case 149 /* StringKeyword */: + case 133 /* BooleanKeyword */: + case 150 /* SymbolKeyword */: + case 147 /* ObjectKeyword */: + case 152 /* UndefinedKeyword */: + case 143 /* NeverKeyword */: return true; case 114 /* VoidKeyword */: - return node.parent.kind !== 215 /* VoidExpression */; - case 226 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 216 /* VoidExpression */; + case 227 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 161 /* TypeParameter */: - return node.parent.kind === 193 /* MappedType */ || node.parent.kind === 188 /* InferType */; + case 162 /* TypeParameter */: + return node.parent.kind === 194 /* MappedType */ || node.parent.kind === 189 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container 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 === 159 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 160 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 204 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 205 /* 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 === 79 /* Identifier */ || node.kind === 159 /* QualifiedName */ || node.kind === 204 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 160 /* QualifiedName */ || node.kind === 205 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 159 /* QualifiedName */: - case 204 /* PropertyAccessExpression */: + case 160 /* QualifiedName */: + case 205 /* PropertyAccessExpression */: case 108 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 179 /* TypeQuery */) { + if (parent.kind === 180 /* TypeQuery */) { return false; } - if (parent.kind === 198 /* ImportType */) { + if (parent.kind === 199 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15259,40 +15324,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 (175 /* FirstTypeNode */ <= parent.kind && parent.kind <= 198 /* LastTypeNode */) { + if (176 /* FirstTypeNode */ <= parent.kind && parent.kind <= 199 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 161 /* TypeParameter */: + case 162 /* TypeParameter */: return node === parent.constraint; - case 339 /* JSDocTemplateTag */: + case 342 /* JSDocTemplateTag */: return node === parent.constraint; - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: - case 162 /* Parameter */: - case 252 /* VariableDeclaration */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 163 /* Parameter */: + case 253 /* VariableDeclaration */: return node === parent.type; - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: - case 169 /* Constructor */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 170 /* Constructor */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return node === parent.type; - case 172 /* CallSignature */: - case 173 /* ConstructSignature */: - case 174 /* IndexSignature */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 175 /* IndexSignature */: return node === parent.type; - case 209 /* TypeAssertionExpression */: + case 210 /* TypeAssertionExpression */: return node === parent.type; - case 206 /* CallExpression */: - case 207 /* NewExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15317,23 +15382,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: return visitor(node); - 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 */: + case 262 /* CaseBlock */: + case 234 /* Block */: + case 238 /* IfStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 247 /* WithStatement */: + case 248 /* SwitchStatement */: + case 288 /* CaseClause */: + case 289 /* DefaultClause */: + case 249 /* LabeledStatement */: + case 251 /* TryStatement */: + case 291 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15343,23 +15408,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 258 /* EnumDeclaration */: - case 256 /* InterfaceDeclaration */: - case 259 /* ModuleDeclaration */: - case 257 /* TypeAliasDeclaration */: + case 259 /* EnumDeclaration */: + case 257 /* InterfaceDeclaration */: + case 260 /* ModuleDeclaration */: + case 258 /* 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 === 160 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 161 /* 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); @@ -15382,10 +15447,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 181 /* ArrayType */) { + if (node && node.kind === 182 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 176 /* TypeReference */) { + else if (node && node.kind === 177 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15395,12 +15460,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 256 /* InterfaceDeclaration */: - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: - case 180 /* TypeLiteral */: + case 257 /* InterfaceDeclaration */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 181 /* TypeLiteral */: return node.members; - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return node.properties; } } @@ -15408,14 +15473,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 201 /* BindingElement */: - case 294 /* EnumMember */: - case 162 /* Parameter */: - case 291 /* PropertyAssignment */: - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: - case 292 /* ShorthandPropertyAssignment */: - case 252 /* VariableDeclaration */: + case 202 /* BindingElement */: + case 297 /* EnumMember */: + case 163 /* Parameter */: + case 294 /* PropertyAssignment */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 295 /* ShorthandPropertyAssignment */: + case 253 /* VariableDeclaration */: return true; } } @@ -15427,8 +15492,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 253 /* VariableDeclarationList */ - && node.parent.parent.kind === 235 /* VariableStatement */; + return node.parent.kind === 254 /* VariableDeclarationList */ + && node.parent.parent.kind === 236 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -15439,13 +15504,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: - case 169 /* Constructor */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: return true; } return false; @@ -15456,7 +15521,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 248 /* LabeledStatement */) { + if (node.statement.kind !== 249 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -15464,19 +15529,19 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 233 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 234 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 167 /* MethodDeclaration */ && node.parent.kind === 203 /* ObjectLiteralExpression */; + return node && node.kind === 168 /* MethodDeclaration */ && node.parent.kind === 204 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; - function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 167 /* MethodDeclaration */ && - (node.parent.kind === 203 /* ObjectLiteralExpression */ || - node.parent.kind === 224 /* ClassExpression */); + function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { + return (node.kind === 168 /* MethodDeclaration */ || node.kind === 171 /* GetAccessor */ || node.kind === 172 /* SetAccessor */) && + (node.parent.kind === 204 /* ObjectLiteralExpression */ || + node.parent.kind === 225 /* ClassExpression */); } - ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; + ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { return predicate && predicate.kind === 1 /* Identifier */; } @@ -15487,7 +15552,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 291 /* PropertyAssignment */) { + if (property.kind === 294 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15549,14 +15614,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 300 /* SourceFile */); + ts.Debug.assert(node.kind !== 303 /* 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 160 /* ComputedPropertyName */: + case 161 /* 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 @@ -15571,9 +15636,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 163 /* Decorator */: + case 164 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 162 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 163 /* 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; @@ -15584,27 +15649,27 @@ var ts; node = node.parent; } break; - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - 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 */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 260 /* ModuleDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 175 /* IndexSignature */: + case 259 /* EnumDeclaration */: + case 303 /* SourceFile */: return node; } } @@ -15623,9 +15688,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 169 /* Constructor */: - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: + case 170 /* Constructor */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: return container; } } @@ -15647,28 +15712,28 @@ var ts; return node; } switch (node.kind) { - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: node = node.parent; break; - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: - case 169 /* Constructor */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 168 /* ClassStaticBlockDeclaration */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 169 /* ClassStaticBlockDeclaration */: return node; - case 163 /* Decorator */: + case 164 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 162 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 163 /* 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; @@ -15684,14 +15749,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 211 /* FunctionExpression */ || func.kind === 212 /* ArrowFunction */) { + if (func.kind === 212 /* FunctionExpression */ || func.kind === 213 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 210 /* ParenthesizedExpression */) { + while (parent.kind === 211 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 206 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 207 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -15707,7 +15772,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 204 /* PropertyAccessExpression */ || kind === 205 /* ElementAccessExpression */) + return (kind === 205 /* PropertyAccessExpression */ || kind === 206 /* ElementAccessExpression */) && node.expression.kind === 106 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -15716,7 +15781,7 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 204 /* PropertyAccessExpression */ || kind === 205 /* ElementAccessExpression */) + return (kind === 205 /* PropertyAccessExpression */ || kind === 206 /* ElementAccessExpression */) && node.expression.kind === 108 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; @@ -15735,15 +15800,15 @@ var ts; ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 176 /* TypeReference */: + case 177 /* TypeReference */: return node.typeName; - case 226 /* ExpressionWithTypeArguments */: + case 227 /* 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 79 /* Identifier */: - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: return node; } return undefined; @@ -15751,10 +15816,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return node.tag; - case 278 /* JsxOpeningElement */: - case 277 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: + case 278 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -15767,25 +15832,25 @@ var ts; return false; } switch (node.kind) { - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: // classes are valid targets return true; - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 255 /* ClassDeclaration */; - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 167 /* MethodDeclaration */: + return parent.kind === 256 /* ClassDeclaration */; + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 168 /* 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 === 255 /* ClassDeclaration */; - case 162 /* Parameter */: + && parent.kind === 256 /* ClassDeclaration */; + case 163 /* 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 === 169 /* Constructor */ - || parent.kind === 167 /* MethodDeclaration */ - || parent.kind === 171 /* SetAccessor */) - && grandparent.kind === 255 /* ClassDeclaration */; + && (parent.kind === 170 /* Constructor */ + || parent.kind === 168 /* MethodDeclaration */ + || parent.kind === 172 /* SetAccessor */) + && grandparent.kind === 256 /* ClassDeclaration */; } return false; } @@ -15801,11 +15866,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 167 /* MethodDeclaration */: - case 171 /* SetAccessor */: - case 169 /* Constructor */: + case 168 /* MethodDeclaration */: + case 172 /* SetAccessor */: + case 170 /* Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -15821,9 +15886,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 278 /* JsxOpeningElement */ || - parent.kind === 277 /* JsxSelfClosingElement */ || - parent.kind === 279 /* JsxClosingElement */) { + if (parent.kind === 279 /* JsxOpeningElement */ || + parent.kind === 278 /* JsxSelfClosingElement */ || + parent.kind === 280 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -15836,49 +15901,51 @@ var ts; case 110 /* TrueKeyword */: case 95 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - 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 */: + case 203 /* ArrayLiteralExpression */: + case 204 /* ObjectLiteralExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: + case 209 /* TaggedTemplateExpression */: + case 228 /* AsExpression */: + case 210 /* TypeAssertionExpression */: + case 229 /* NonNullExpression */: + case 211 /* ParenthesizedExpression */: + case 212 /* FunctionExpression */: + case 225 /* ClassExpression */: + case 213 /* ArrowFunction */: + case 216 /* VoidExpression */: + case 214 /* DeleteExpression */: + case 215 /* TypeOfExpression */: + case 218 /* PrefixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: + case 220 /* BinaryExpression */: + case 221 /* ConditionalExpression */: + case 224 /* SpreadElement */: + case 222 /* TemplateExpression */: + case 226 /* OmittedExpression */: + case 277 /* JsxElement */: + case 278 /* JsxSelfClosingElement */: + case 281 /* JsxFragment */: + case 223 /* YieldExpression */: + case 217 /* AwaitExpression */: + case 230 /* MetaProperty */: return true; - case 159 /* QualifiedName */: - while (node.parent.kind === 159 /* QualifiedName */) { + case 160 /* QualifiedName */: + while (node.parent.kind === 160 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 179 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 306 /* JSDocMemberName */: + return node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 309 /* 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); + return node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; case 79 /* Identifier */: - if (node.parent.kind === 179 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + if (node.parent.kind === 180 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through @@ -15896,49 +15963,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 252 /* VariableDeclaration */: - case 162 /* Parameter */: - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: - case 294 /* EnumMember */: - case 291 /* PropertyAssignment */: - case 201 /* BindingElement */: + case 253 /* VariableDeclaration */: + case 163 /* Parameter */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 297 /* EnumMember */: + case 294 /* PropertyAssignment */: + case 202 /* BindingElement */: return parent.initializer === node; - 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 */: + case 237 /* ExpressionStatement */: + case 238 /* IfStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: + case 246 /* ReturnStatement */: + case 247 /* WithStatement */: + case 248 /* SwitchStatement */: + case 288 /* CaseClause */: + case 250 /* ThrowStatement */: return parent.expression === node; - case 240 /* ForStatement */: + case 241 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 253 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 254 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 253 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 254 /* VariableDeclarationList */) || forInStatement.expression === node; - case 209 /* TypeAssertionExpression */: - case 227 /* AsExpression */: + case 210 /* TypeAssertionExpression */: + case 228 /* AsExpression */: return node === parent.expression; - case 231 /* TemplateSpan */: + case 232 /* TemplateSpan */: return node === parent.expression; - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: return node === parent.expression; - case 163 /* Decorator */: - case 286 /* JsxExpression */: - case 285 /* JsxSpreadAttribute */: - case 293 /* SpreadAssignment */: + case 164 /* Decorator */: + case 287 /* JsxExpression */: + case 286 /* JsxSpreadAttribute */: + case 296 /* SpreadAssignment */: return true; - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -15946,10 +16013,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 159 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 160 /* QualifiedName */ || node.kind === 79 /* Identifier */) { node = node.parent; } - return node.kind === 179 /* TypeQuery */; + return node.kind === 180 /* TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -15957,7 +16024,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 263 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 275 /* ExternalModuleReference */; + return node.kind === 264 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 276 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -15970,7 +16037,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 263 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 275 /* ExternalModuleReference */; + return node.kind === 264 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 276 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16002,11 +16069,11 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 148 /* StringKeyword */ || node.typeArguments[0].kind === 145 /* NumberKeyword */); + (node.typeArguments[0].kind === 149 /* StringKeyword */ || node.typeArguments[0].kind === 146 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 206 /* CallExpression */) { + if (callExpression.kind !== 207 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -16025,7 +16092,7 @@ var ts; * This function does not test if the node is in a JavaScript file or not. */ function isRequireVariableDeclaration(node) { - if (node.kind === 201 /* BindingElement */) { + if (node.kind === 202 /* BindingElement */) { node = node.parent.parent; } return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); @@ -16106,11 +16173,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 211 /* FunctionExpression */ || e.kind === 212 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 212 /* FunctionExpression */ || e.kind === 213 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 211 /* FunctionExpression */ || - initializer.kind === 224 /* ClassExpression */ || - initializer.kind === 212 /* ArrowFunction */) { + if (initializer.kind === 212 /* FunctionExpression */ || + initializer.kind === 225 /* ClassExpression */ || + initializer.kind === 213 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16360,7 +16427,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 236 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 237 /* ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16381,17 +16448,17 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 254 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 255 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { var _a, _b, _c; switch (node.kind) { - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return node.initializer.arguments[0].text; - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; - case 263 /* ImportEqualsDeclaration */: + case 264 /* 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); @@ -16404,14 +16471,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 264 /* ImportDeclaration */: - case 270 /* ExportDeclaration */: + case 265 /* ImportDeclaration */: + case 271 /* ExportDeclaration */: return node.parent; - case 275 /* ExternalModuleReference */: + case 276 /* ExternalModuleReference */: return node.parent.parent; - case 206 /* CallExpression */: + case 207 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 194 /* LiteralType */: + case 195 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16421,16 +16488,16 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 264 /* ImportDeclaration */: - case 270 /* ExportDeclaration */: + case 265 /* ImportDeclaration */: + case 271 /* ExportDeclaration */: return node.moduleSpecifier; - case 263 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 275 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 198 /* ImportType */: + case 264 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 276 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 199 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 206 /* CallExpression */: + case 207 /* CallExpression */: return node.arguments[0]; - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); @@ -16439,11 +16506,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return node; - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16451,7 +16518,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 264 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 265 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16472,13 +16539,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 162 /* Parameter */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: - case 292 /* ShorthandPropertyAssignment */: - case 291 /* PropertyAssignment */: - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: + case 163 /* Parameter */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 295 /* ShorthandPropertyAssignment */: + case 294 /* PropertyAssignment */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -16492,7 +16559,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 340 /* JSDocTypedefTag */ || node.kind === 333 /* JSDocCallbackTag */ || node.kind === 334 /* JSDocEnumTag */; + return node.kind === 343 /* JSDocTypedefTag */ || node.kind === 336 /* JSDocCallbackTag */ || node.kind === 337 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16517,12 +16584,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return node.initializer; - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: return node.initializer; } } @@ -16534,7 +16601,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 259 /* ModuleDeclaration */ + node.body.kind === 260 /* ModuleDeclaration */ ? node.body : undefined; } @@ -16542,18 +16609,18 @@ var ts; var result; // Pull parameter comments from declaring function as well if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) { - result = ts.append(result, ts.last(hostNode.initializer.jsDoc)); + result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(hostNode.initializer.jsDoc))); } var node = hostNode; while (node && node.parent) { if (ts.hasJSDocNodes(node)) { - result = ts.append(result, ts.last(node.jsDoc)); + result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 162 /* Parameter */) { + if (node.kind === 163 /* Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 161 /* TypeParameter */) { + if (node.kind === 162 /* TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -16562,13 +16629,31 @@ var ts; return result || ts.emptyArray; } ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; + function filterOwnedJSDocTags(hostNode, jsDoc) { + if (ts.isJSDoc(jsDoc)) { + var ownedTags = ts.filter(jsDoc.tags, function (tag) { return ownsJSDocTag(hostNode, tag); }); + return jsDoc.tags === ownedTags ? [jsDoc] : ownedTags; + } + return ownsJSDocTag(hostNode, jsDoc) ? [jsDoc] : undefined; + } + /** + * Determines whether a host node owns a jsDoc tag. A `@type` tag attached to a + * a ParenthesizedExpression belongs only to the ParenthesizedExpression. + */ + function ownsJSDocTag(hostNode, tag) { + return !ts.isJSDocTypeTag(tag) + || !tag.parent + || !ts.isJSDoc(tag.parent) + || !ts.isParenthesizedExpression(tag.parent.parent) + || tag.parent.parent === hostNode; + } function getNextJSDocCommentLocation(node) { var parent = node.parent; - 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 */ || + if (parent.kind === 294 /* PropertyAssignment */ || + parent.kind === 270 /* ExportAssignment */ || + parent.kind === 166 /* PropertyDeclaration */ || + parent.kind === 237 /* ExpressionStatement */ && node.kind === 205 /* PropertyAccessExpression */ || + parent.kind === 246 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { return parent; @@ -16609,6 +16694,18 @@ var ts; return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; + function getEffectiveContainerForJSDocTemplateTag(node) { + if (ts.isJSDoc(node.parent) && node.parent.tags) { + // A @template tag belongs to any @typedef, @callback, or @enum tags in the same comment block, if they exist. + var typeAlias = ts.find(node.parent.tags, isJSDocTypeAlias); + if (typeAlias) { + return typeAlias; + } + } + // otherwise it belongs to the host it annotates + return getHostSignatureFromJSDoc(node); + } + ts.getEffectiveContainerForJSDocTemplateTag = getEffectiveContainerForJSDocTemplateTag; function getHostSignatureFromJSDoc(node) { var host = getEffectiveJSDocHost(node); return host && ts.isFunctionLike(host) ? host : undefined; @@ -16655,7 +16752,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 === 313 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 316 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -16672,34 +16769,34 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 217 /* PrefixUnaryExpression */: - case 218 /* PostfixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 210 /* ParenthesizedExpression */: - case 202 /* ArrayLiteralExpression */: - case 223 /* SpreadElement */: - case 228 /* NonNullExpression */: + case 211 /* ParenthesizedExpression */: + case 203 /* ArrayLiteralExpression */: + case 224 /* SpreadElement */: + case 229 /* NonNullExpression */: node = parent; break; - case 293 /* SpreadAssignment */: + case 296 /* SpreadAssignment */: node = parent.parent; break; - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -16726,22 +16823,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - 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 */: + case 234 /* Block */: + case 236 /* VariableStatement */: + case 247 /* WithStatement */: + case 238 /* IfStatement */: + case 248 /* SwitchStatement */: + case 262 /* CaseBlock */: + case 288 /* CaseClause */: + case 289 /* DefaultClause */: + case 249 /* LabeledStatement */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: + case 251 /* TryStatement */: + case 291 /* CatchClause */: return true; } return false; @@ -16758,11 +16855,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 189 /* ParenthesizedType */); + return walkUp(node, 190 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 210 /* ParenthesizedExpression */); + return walkUp(node, 211 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -16772,24 +16869,27 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 189 /* ParenthesizedType */) { + while (node && node.kind === 190 /* ParenthesizedType */) { child = node; node = node.parent; } return [child, node]; } ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild; - function skipParentheses(node) { - return ts.skipOuterExpressions(node, 1 /* Parentheses */); + function skipParentheses(node, excludeJSDocTypeAssertions) { + var flags = excludeJSDocTypeAssertions ? + 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : + 1 /* Parentheses */; + return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 204 /* PropertyAccessExpression */ && node.kind !== 205 /* ElementAccessExpression */) { + if (node.kind !== 205 /* PropertyAccessExpression */ && node.kind !== 206 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 213 /* DeleteExpression */; + return node && node.kind === 214 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -16842,7 +16942,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 160 /* ComputedPropertyName */ && + node.parent.kind === 161 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -16850,26 +16950,26 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - 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 */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 297 /* EnumMember */: + case 294 /* PropertyAssignment */: + case 205 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 201 /* BindingElement */: - case 268 /* ImportSpecifier */: + case 202 /* BindingElement */: + case 269 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 273 /* ExportSpecifier */: - case 283 /* JsxAttribute */: + case 274 /* ExportSpecifier */: + case 284 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -16889,33 +16989,33 @@ var ts; // {} // {name: } function isAliasSymbolDeclaration(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) || + return node.kind === 264 /* ImportEqualsDeclaration */ || + node.kind === 263 /* NamespaceExportDeclaration */ || + node.kind === 266 /* ImportClause */ && !!node.name || + node.kind === 267 /* NamespaceImport */ || + node.kind === 273 /* NamespaceExport */ || + node.kind === 269 /* ImportSpecifier */ || + node.kind === 274 /* ExportSpecifier */ || + node.kind === 270 /* 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 === 63 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 292 /* ShorthandPropertyAssignment */ || - node.kind === 291 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + node.kind === 295 /* ShorthandPropertyAssignment */ || + node.kind === 294 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 265 /* ImportClause */: - case 268 /* ImportSpecifier */: - case 266 /* NamespaceImport */: - case 273 /* ExportSpecifier */: - case 269 /* ExportAssignment */: - case 263 /* ImportEqualsDeclaration */: + case 266 /* ImportClause */: + case 269 /* ImportSpecifier */: + case 267 /* NamespaceImport */: + case 274 /* ExportSpecifier */: + case 270 /* ExportAssignment */: + case 264 /* ImportEqualsDeclaration */: return node.parent; - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 159 /* QualifiedName */); + } while (node.parent.kind === 160 /* QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -16934,7 +17034,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 292 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 291 /* PropertyAssignment */ ? node.initializer : + return node.kind === 295 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 294 /* PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17000,11 +17100,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 158 /* LastKeyword */; + return 81 /* FirstKeyword */ <= token && token <= 159 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 158 /* LastContextualKeyword */; + return 126 /* FirstContextualKeyword */ <= token && token <= 159 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17048,14 +17148,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 167 /* MethodDeclaration */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 168 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: if (hasSyntacticModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -17069,10 +17169,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: - case 167 /* MethodDeclaration */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 168 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasSyntacticModifier(node, 256 /* Async */); @@ -17102,7 +17202,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 160 /* ComputedPropertyName */ || name.kind === 205 /* ElementAccessExpression */)) { + if (!(name.kind === 161 /* ComputedPropertyName */ || name.kind === 206 /* ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17118,7 +17218,7 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); @@ -17184,11 +17284,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 162 /* Parameter */; + return root.kind === 163 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 201 /* BindingElement */) { + while (node.kind === 202 /* BindingElement */) { node = node.parent.parent; } return node; @@ -17196,15 +17296,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - 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 */; + return kind === 170 /* Constructor */ + || kind === 212 /* FunctionExpression */ + || kind === 255 /* FunctionDeclaration */ + || kind === 213 /* ArrowFunction */ + || kind === 168 /* MethodDeclaration */ + || kind === 171 /* GetAccessor */ + || kind === 172 /* SetAccessor */ + || kind === 260 /* ModuleDeclaration */ + || kind === 303 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17223,23 +17323,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 207 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 208 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 207 /* NewExpression */: + case 208 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 217 /* PrefixUnaryExpression */: - case 214 /* TypeOfExpression */: - case 215 /* VoidExpression */: - case 213 /* DeleteExpression */: - case 216 /* AwaitExpression */: - case 220 /* ConditionalExpression */: - case 222 /* YieldExpression */: + case 218 /* PrefixUnaryExpression */: + case 215 /* TypeOfExpression */: + case 216 /* VoidExpression */: + case 214 /* DeleteExpression */: + case 217 /* AwaitExpression */: + case 221 /* ConditionalExpression */: + case 223 /* YieldExpression */: return 1 /* Right */; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: switch (operator) { case 42 /* AsteriskAsteriskToken */: case 63 /* EqualsToken */: @@ -17266,15 +17366,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 207 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 208 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 219 /* BinaryExpression */) { + if (expression.kind === 220 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 217 /* PrefixUnaryExpression */ || expression.kind === 218 /* PostfixUnaryExpression */) { + else if (expression.kind === 218 /* PrefixUnaryExpression */ || expression.kind === 219 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -17453,15 +17553,15 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 346 /* CommaListExpression */: + case 349 /* CommaListExpression */: return 0 /* Comma */; - case 223 /* SpreadElement */: + case 224 /* SpreadElement */: return 1 /* Spread */; - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: return 2 /* Yield */; - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: return 4 /* Conditional */; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0 /* Comma */; @@ -17486,49 +17586,50 @@ var ts; return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 209 /* TypeAssertionExpression */: - case 228 /* NonNullExpression */: - case 217 /* PrefixUnaryExpression */: - case 214 /* TypeOfExpression */: - case 215 /* VoidExpression */: - case 213 /* DeleteExpression */: - case 216 /* AwaitExpression */: + case 210 /* TypeAssertionExpression */: + case 229 /* NonNullExpression */: + case 218 /* PrefixUnaryExpression */: + case 215 /* TypeOfExpression */: + case 216 /* VoidExpression */: + case 214 /* DeleteExpression */: + case 217 /* AwaitExpression */: return 16 /* Unary */; - case 218 /* PostfixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: return 17 /* Update */; - case 206 /* CallExpression */: + case 207 /* CallExpression */: return 18 /* LeftHandSide */; - case 207 /* NewExpression */: + case 208 /* NewExpression */: return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 208 /* TaggedTemplateExpression */: - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: - case 229 /* MetaProperty */: + case 209 /* TaggedTemplateExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: + case 230 /* MetaProperty */: return 19 /* Member */; - case 227 /* AsExpression */: + case 228 /* AsExpression */: return 11 /* Relational */; case 108 /* ThisKeyword */: case 106 /* SuperKeyword */: case 79 /* Identifier */: + case 80 /* PrivateIdentifier */: case 104 /* NullKeyword */: case 110 /* TrueKeyword */: case 95 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 202 /* ArrayLiteralExpression */: - case 203 /* ObjectLiteralExpression */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: - case 224 /* ClassExpression */: + case 203 /* ArrayLiteralExpression */: + case 204 /* ObjectLiteralExpression */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 225 /* ClassExpression */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 221 /* TemplateExpression */: - case 210 /* ParenthesizedExpression */: - case 225 /* OmittedExpression */: - case 276 /* JsxElement */: - case 277 /* JsxSelfClosingElement */: - case 280 /* JsxFragment */: + case 222 /* TemplateExpression */: + case 211 /* ParenthesizedExpression */: + case 226 /* OmittedExpression */: + case 277 /* JsxElement */: + case 278 /* JsxSelfClosingElement */: + case 281 /* JsxFragment */: return 20 /* Primary */; default: return -1 /* Invalid */; @@ -17584,7 +17685,7 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 286 /* JsxExpression */: + case 287 /* JsxExpression */: return !!i.expression; case 11 /* JsxText */: return !i.containsOnlyTriviaWhiteSpaces; @@ -18016,9 +18117,17 @@ var ts; var path = outputDir ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName) : fileName; - return removeFileExtension(path) + ".d.ts" /* Dts */; + var declarationExtension = getDeclarationEmitExtensionForPath(path); + return removeFileExtension(path) + declarationExtension; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; + function getDeclarationEmitExtensionForPath(path) { + return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Dts */; + } + ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; function outFile(options) { return options.outFile || options.out; } @@ -18154,7 +18263,7 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 179 /* TypeQuery */; + return node.parent.kind === 180 /* TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { @@ -18169,10 +18278,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 170 /* GetAccessor */) { + if (accessor.kind === 171 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 171 /* SetAccessor */) { + else if (accessor.kind === 172 /* SetAccessor */) { setAccessor = accessor; } else { @@ -18192,10 +18301,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 170 /* GetAccessor */ && !getAccessor) { + if (member.kind === 171 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 171 /* SetAccessor */ && !setAccessor) { + if (member.kind === 172 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18244,7 +18353,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 === 315 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 318 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18497,7 +18606,7 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 158 /* LastToken */) { + if (node.kind >= 0 /* FirstToken */ && node.kind <= 159 /* LastToken */) { return 0 /* None */; } if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { @@ -18591,12 +18700,12 @@ var ts; 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 135 /* 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 */; + case 131 /* AsyncKeyword */: return 256 /* Async */; + case 144 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 158 /* OverrideKeyword */: return 16384 /* Override */; } return 0 /* None */; } @@ -18654,8 +18763,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 203 /* ObjectLiteralExpression */ - || kind === 202 /* ArrayLiteralExpression */; + return kind === 204 /* ObjectLiteralExpression */ + || kind === 203 /* ArrayLiteralExpression */; } return false; } @@ -18672,12 +18781,12 @@ var ts; switch (node.kind) { case 79 /* Identifier */: return node; - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: do { node = node.left; } while (node.kind !== 79 /* Identifier */); return node; - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 79 /* Identifier */); @@ -18689,9 +18798,9 @@ var ts; 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); + || node.kind === 230 /* MetaProperty */ + || node.kind === 205 /* PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 211 /* ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -18722,8 +18831,8 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 159 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 204 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 160 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 205 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName(node) { @@ -18733,12 +18842,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 203 /* ObjectLiteralExpression */ && + return expression.kind === 204 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 202 /* ArrayLiteralExpression */ && + return expression.kind === 203 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -18758,7 +18867,7 @@ var ts; } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { - return ts.find(ts.supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); + return ts.find(supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } ts.tryExtractTSExtension = tryExtractTSExtension; /** @@ -19070,8 +19179,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 258 /* EnumDeclaration */: - case 259 /* ModuleDeclaration */: + case 259 /* EnumDeclaration */: + case 260 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19101,7 +19210,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 === 171 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 172 /* SetAccessor */; })) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; } @@ -19150,35 +19259,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return accessKind(parent); - case 218 /* PostfixUnaryExpression */: - case 217 /* PrefixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 291 /* PropertyAssignment */: { + case 294 /* 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 292 /* ShorthandPropertyAssignment */: + case 295 /* 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 202 /* ArrayLiteralExpression */: + case 203 /* 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 && walkUpParenthesizedExpressions(parent.parent).kind === 236 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 237 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -19322,37 +19431,37 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - 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 */ + return (kind >= 176 /* FirstTypeNode */ && kind <= 199 /* LastTypeNode */) + || kind === 130 /* AnyKeyword */ + || kind === 154 /* UnknownKeyword */ + || kind === 146 /* NumberKeyword */ + || kind === 157 /* BigIntKeyword */ + || kind === 147 /* ObjectKeyword */ + || kind === 133 /* BooleanKeyword */ + || kind === 149 /* StringKeyword */ + || kind === 150 /* 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 */; + || kind === 152 /* UndefinedKeyword */ + || kind === 143 /* NeverKeyword */ + || kind === 227 /* ExpressionWithTypeArguments */ + || kind === 310 /* JSDocAllType */ + || kind === 311 /* JSDocUnknownType */ + || kind === 312 /* JSDocNullableType */ + || kind === 313 /* JSDocNonNullableType */ + || kind === 314 /* JSDocOptionalType */ + || kind === 315 /* JSDocFunctionType */ + || kind === 316 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 204 /* PropertyAccessExpression */ || node.kind === 205 /* ElementAccessExpression */; + return node.kind === 205 /* PropertyAccessExpression */ || node.kind === 206 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 204 /* PropertyAccessExpression */) { + if (node.kind === 205 /* PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 205 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 206 /* ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; @@ -19367,7 +19476,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 267 /* NamedImports */ || node.kind === 271 /* NamedExports */; + return node.kind === 268 /* NamedImports */ || node.kind === 272 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19380,28 +19489,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 218 /* PostfixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: node = node.operand; continue; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: node = node.left; continue; - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: node = node.condition; continue; - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: node = node.tag; continue; - case 206 /* CallExpression */: + case 207 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 227 /* AsExpression */: - case 205 /* ElementAccessExpression */: - case 204 /* PropertyAccessExpression */: - case 228 /* NonNullExpression */: - case 345 /* PartiallyEmittedExpression */: + case 228 /* AsExpression */: + case 206 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 229 /* NonNullExpression */: + case 348 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -19710,7 +19819,10 @@ var ts; } ts.getLanguageVariant = getLanguageVariant; function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0 /* ES3 */; + return compilerOptions.target || + (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || + 0 /* ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { @@ -19722,7 +19834,20 @@ var ts; function getEmitModuleResolutionKind(compilerOptions) { var moduleResolution = compilerOptions.moduleResolution; if (moduleResolution === undefined) { - moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + switch (getEmitModuleKind(compilerOptions)) { + case ts.ModuleKind.CommonJS: + moduleResolution = ts.ModuleResolutionKind.NodeJs; + break; + case ts.ModuleKind.Node12: + moduleResolution = ts.ModuleResolutionKind.Node12; + break; + case ts.ModuleKind.NodeNext: + moduleResolution = ts.ModuleResolutionKind.NodeNext; + break; + default: + moduleResolution = ts.ModuleResolutionKind.Classic; + break; + } } return moduleResolution; } @@ -19733,7 +19858,10 @@ var ts; case ts.ModuleKind.AMD: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: + case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: + case ts.ModuleKind.Node12: + case ts.ModuleKind.NodeNext: return true; default: return false; @@ -19752,11 +19880,23 @@ var ts; return !!(getEmitDeclarations(options) && options.declarationMap); } ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; + function getESModuleInterop(compilerOptions) { + if (compilerOptions.esModuleInterop !== undefined) { + return compilerOptions.esModuleInterop; + } + switch (getEmitModuleKind(compilerOptions)) { + case ts.ModuleKind.Node12: + case ts.ModuleKind.NodeNext: + return true; + } + return undefined; + } + ts.getESModuleInterop = getESModuleInterop; function getAllowSyntheticDefaultImports(compilerOptions) { var moduleKind = getEmitModuleKind(compilerOptions); return compilerOptions.allowSyntheticDefaultImports !== undefined ? compilerOptions.allowSyntheticDefaultImports - : compilerOptions.esModuleInterop || + : getESModuleInterop(compilerOptions) || moduleKind === ts.ModuleKind.System; } ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; @@ -19781,7 +19921,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? compilerOptions.target === 99 /* ESNext */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -19894,7 +20034,8 @@ var ts; var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd)); var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd)); var isDirectory = false; - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + while (aParts.length >= 2 && bParts.length >= 2 && + !isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { aParts.pop(); @@ -19906,7 +20047,7 @@ var ts; // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); + return s !== undefined && (getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@")); } function stripLeadingDirectorySeparator(s) { return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; @@ -20085,7 +20226,7 @@ var ts; } ts.getRegexFromPattern = getRegexFromPattern; /** @param path directory of the tsconfig.json */ - function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath, directoryExists) { + function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath) { path = ts.normalizePath(path); currentDirectory = ts.normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); @@ -20099,9 +20240,7 @@ var ts; var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; - if (directoryExists(basePath)) { - visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth); - } + visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth); } return ts.flatten(results); function visitDirectory(path, absolutePath, depth) { @@ -20206,10 +20345,14 @@ var ts; var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { case ".js" /* Js */: + case ".cjs" /* Cjs */: + case ".mjs" /* Mjs */: return 1 /* JS */; case ".jsx" /* Jsx */: return 2 /* JSX */; case ".ts" /* Ts */: + case ".cts" /* Cts */: + case ".mts" /* Mts */: return 3 /* TS */; case ".tsx" /* Tsx */: return 4 /* TSX */; @@ -20221,55 +20364,54 @@ var ts; } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** - * List of supported extensions in order of file resolution precedence. + * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */]; - ts.supportedTSExtensionsWithJson = [".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".json" /* Json */]; + ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.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, true), ts.supportedJSExtensions, true); - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray(__spreadArray([], ts.supportedTSExtensions, true), ts.supportedJSExtensions, true), [".json" /* Json */], false); + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; + ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); + var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, 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, 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); + var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; + var flatBuiltins = ts.flatten(builtins); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + return extensions; } ts.getSupportedExtensions = getSupportedExtensions; - function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) { - if (!options || !options.resolveJsonModule) { + function getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) { + if (!options || !options.resolveJsonModule) return supportedExtensions; - } - if (supportedExtensions === allSupportedExtensions) { + if (supportedExtensions === allSupportedExtensions) return allSupportedExtensionsWithJson; - } - if (supportedExtensions === ts.supportedTSExtensions) { - return ts.supportedTSExtensionsWithJson; - } - return __spreadArray(__spreadArray([], supportedExtensions, true), [".json" /* Json */], false); + if (supportedExtensions === ts.supportedTSExtensions) + return supportedTSExtensionsWithJson; + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); } - ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule; + ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; } function hasJSFileExtension(fileName) { - return ts.some(ts.supportedJSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); + return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } ts.hasJSFileExtension = hasJSFileExtension; function hasTSFileExtension(fileName) { - return ts.some(ts.supportedTSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); }); + return ts.some(ts.supportedTSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } ts.hasTSFileExtension = hasTSFileExtension; function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) { - if (!fileName) { + if (!fileName) return false; - } var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions); - for (var _i = 0, _a = getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.flatten(getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions)); _i < _a.length; _i++) { var extension = _a[_i]; if (ts.fileExtensionIs(fileName, extension)) { return true; @@ -20286,57 +20428,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - /** - * Extension boundaries by priority. Lower numbers indicate higher priorities, and are - * aligned to the offset of the highest priority extension in the - * allSupportedExtensions array. - */ - var ExtensionPriority; - (function (ExtensionPriority) { - ExtensionPriority[ExtensionPriority["TypeScriptFiles"] = 0] = "TypeScriptFiles"; - ExtensionPriority[ExtensionPriority["DeclarationAndJavaScriptFiles"] = 2] = "DeclarationAndJavaScriptFiles"; - ExtensionPriority[ExtensionPriority["Highest"] = 0] = "Highest"; - ExtensionPriority[ExtensionPriority["Lowest"] = 2] = "Lowest"; - })(ExtensionPriority = ts.ExtensionPriority || (ts.ExtensionPriority = {})); - function getExtensionPriority(path, supportedExtensions) { - for (var i = supportedExtensions.length - 1; i >= 0; i--) { - if (ts.fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i, supportedExtensions); - } - } - // If its not in the list of supported extensions, this is likely a - // TypeScript file with a non-ts extension - return 0 /* Highest */; - } - ts.getExtensionPriority = getExtensionPriority; - /** - * Adjusts an extension priority to be the highest priority within the same range. - */ - function adjustExtensionPriority(extensionPriority, supportedExtensions) { - if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) { - return 0 /* TypeScriptFiles */; - } - else if (extensionPriority < supportedExtensions.length) { - return 2 /* DeclarationAndJavaScriptFiles */; - } - else { - return supportedExtensions.length; - } - } - ts.adjustExtensionPriority = adjustExtensionPriority; - /** - * Gets the next lowest extension priority for a given priority. - */ - function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) { - if (extensionPriority < 2 /* DeclarationAndJavaScriptFiles */) { - return 2 /* DeclarationAndJavaScriptFiles */; - } - else { - return supportedExtensions.length; - } - } - ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; - var extensionsToRemove = [".d.ts" /* Dts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -20389,7 +20481,7 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */; + return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { @@ -20588,25 +20680,21 @@ var ts; || !(isExpressionNode(useSite) || isShorthandPropertyNameUseSite(useSite)); } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; - function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { - 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 === 79 /* Identifier */ || node.kind === 204 /* PropertyAccessExpression */) { + while (node.kind === 79 /* Identifier */ || node.kind === 205 /* PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 160 /* ComputedPropertyName */) { + if (node.kind !== 161 /* ComputedPropertyName */) { return false; } if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 256 /* InterfaceDeclaration */ || containerKind === 180 /* TypeLiteral */; + return containerKind === 257 /* InterfaceDeclaration */ || containerKind === 181 /* TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { @@ -20614,16 +20702,16 @@ var ts; return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 289 /* HeritageClause */: + case 290 /* HeritageClause */: return true; - case 204 /* PropertyAccessExpression */: - case 226 /* ExpressionWithTypeArguments */: + case 205 /* PropertyAccessExpression */: + case 227 /* ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 256 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 257 /* InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -20784,18 +20872,18 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 161 /* TypeParameter */: + case 162 /* TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 188 /* InferType */ ? undefined : parent_1.typeParameters; - case 162 /* Parameter */: + return parent_1.kind === 189 /* InferType */ ? undefined : parent_1.typeParameters; + case 163 /* Parameter */: return node.parent.parameters; - case 197 /* TemplateLiteralTypeSpan */: + case 198 /* TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 231 /* TemplateSpan */: + case 232 /* TemplateSpan */: return node.parent.templateSpans; - case 163 /* Decorator */: + case 164 /* Decorator */: return node.parent.decorators; - case 289 /* HeritageClause */: + case 290 /* HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -20803,45 +20891,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 180 /* TypeLiteral */: - case 256 /* InterfaceDeclaration */: + case 181 /* TypeLiteral */: + case 257 /* InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 185 /* UnionType */: - case 186 /* IntersectionType */: + case 186 /* UnionType */: + case 187 /* IntersectionType */: return parent.types; - case 182 /* TupleType */: - case 202 /* ArrayLiteralExpression */: - case 346 /* CommaListExpression */: - case 267 /* NamedImports */: - case 271 /* NamedExports */: + case 183 /* TupleType */: + case 203 /* ArrayLiteralExpression */: + case 349 /* CommaListExpression */: + case 268 /* NamedImports */: + case 272 /* NamedExports */: return parent.elements; - case 203 /* ObjectLiteralExpression */: - case 284 /* JsxAttributes */: + case 204 /* ObjectLiteralExpression */: + case 285 /* JsxAttributes */: return parent.properties; - case 206 /* CallExpression */: - case 207 /* NewExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 276 /* JsxElement */: - case 280 /* JsxFragment */: + case 277 /* JsxElement */: + case 281 /* JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 278 /* JsxOpeningElement */: - case 277 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: + case 278 /* JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 233 /* Block */: - case 287 /* CaseClause */: - case 288 /* DefaultClause */: - case 260 /* ModuleBlock */: + case 234 /* Block */: + case 288 /* CaseClause */: + case 289 /* DefaultClause */: + case 261 /* ModuleBlock */: return parent.statements; - case 261 /* CaseBlock */: + case 262 /* CaseBlock */: return parent.clauses; - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 300 /* SourceFile */: + case 303 /* SourceFile */: return parent.statements; } } @@ -20853,7 +20941,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 212 /* ArrowFunction */) { + if (node.kind !== 213 /* 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); @@ -20870,6 +20958,23 @@ var ts; return name === "Infinity" || name === "-Infinity" || name === "NaN"; } ts.isInfinityOrNaNString = isInfinityOrNaNString; + function isCatchClauseVariableDeclaration(node) { + return node.kind === 253 /* VariableDeclaration */ && node.parent.kind === 291 /* CatchClause */; + } + ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; + function isParameterOrCatchClauseVariable(symbol) { + var declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration); + return !!declaration && (ts.isParameter(declaration) || isCatchClauseVariableDeclaration(declaration)); + } + ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; + function isFunctionExpressionOrArrowFunction(node) { + return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */; + } + ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; + function escapeSnippetText(text) { + return text.replace(/\$/gm, "\\$"); + } + ts.escapeSnippetText = escapeSnippetText; })(ts || (ts = {})); /* @internal */ var ts; @@ -20983,10 +21088,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(219 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(219 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(220 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(220 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 212 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 213 /* 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; @@ -20998,7 +21103,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 222 /* YieldExpression */) { + && operand.kind === 223 /* YieldExpression */) { return false; } return true; @@ -21086,7 +21191,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 219 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 220 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21112,7 +21217,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 === 210 /* ParenthesizedExpression */) { + if (skipped.kind === 211 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21129,7 +21234,7 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(220 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(221 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { @@ -21162,8 +21267,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 224 /* ClassExpression */: - case 211 /* FunctionExpression */: + case 225 /* ClassExpression */: + case 212 /* FunctionExpression */: needsParens = true; } } @@ -21176,9 +21281,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 206 /* CallExpression */: + case 207 /* CallExpression */: return factory.createParenthesizedExpression(expression); - case 207 /* NewExpression */: + case 208 /* NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21198,7 +21303,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 207 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 208 /* NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21220,7 +21325,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(219 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(220 /* BinaryExpression */, 27 /* CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21229,44 +21334,44 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 211 /* FunctionExpression */ || kind === 212 /* ArrowFunction */) { + if (kind === 212 /* FunctionExpression */ || kind === 213 /* 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 === 203 /* ObjectLiteralExpression */ || leftmostExpressionKind === 211 /* FunctionExpression */) { + if (leftmostExpressionKind === 204 /* ObjectLiteralExpression */ || leftmostExpressionKind === 212 /* 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 === 203 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 204 /* ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } return body; } function parenthesizeMemberOfConditionalType(member) { - return member.kind === 187 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; + return member.kind === 188 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; } function parenthesizeMemberOfElementType(member) { switch (member.kind) { - case 185 /* UnionType */: - case 186 /* IntersectionType */: - case 177 /* FunctionType */: - case 178 /* ConstructorType */: + case 186 /* UnionType */: + case 187 /* IntersectionType */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfConditionalType(member); } function parenthesizeElementTypeOfArrayType(member) { switch (member.kind) { - case 179 /* TypeQuery */: - case 191 /* TypeOperator */: - case 188 /* InferType */: + case 180 /* TypeQuery */: + case 192 /* TypeOperator */: + case 189 /* InferType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfElementType(member); @@ -21372,11 +21477,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 200 /* ArrayBindingPattern */: - case 202 /* ArrayLiteralExpression */: + case 201 /* ArrayBindingPattern */: + case 203 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 199 /* ObjectBindingPattern */: - case 203 /* ObjectLiteralExpression */: + case 200 /* ObjectBindingPattern */: + case 204 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -21699,6 +21804,10 @@ var ts; updateImportDeclaration: updateImportDeclaration, createImportClause: createImportClause, updateImportClause: updateImportClause, + createAssertClause: createAssertClause, + updateAssertClause: updateAssertClause, + createAssertEntry: createAssertEntry, + updateAssertEntry: updateAssertEntry, createNamespaceImport: createNamespaceImport, updateNamespaceImport: updateNamespaceImport, createNamespaceExport: createNamespaceExport, @@ -21719,18 +21828,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - 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 */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(310 /* JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(311 /* JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(313 /* JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(313 /* JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(312 /* JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(312 /* JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(314 /* JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(314 /* JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(317 /* JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(317 /* JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -21766,30 +21875,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - 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 */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(340 /* JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(340 /* JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(337 /* JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(337 /* JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(328 /* JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(328 /* JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(329 /* JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(329 /* JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -21992,11 +22101,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 165 /* PropertyDeclaration */: - case 291 /* PropertyAssignment */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 166 /* PropertyDeclaration */: + case 294 /* PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22164,7 +22273,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 === 131 /* AwaitKeyword */) { + if (node.originalKeywordKind === 132 /* AwaitKeyword */) { node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; } return node; @@ -22227,14 +22336,14 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 158 /* LastToken */, "Invalid token"); + ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 159 /* 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 !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); var transformFlags = 0 /* None */; switch (token) { - case 130 /* AsyncKeyword */: + case 131 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = 128 /* ContainsES2017 */ | @@ -22243,22 +22352,22 @@ var ts; case 123 /* PublicKeyword */: case 121 /* PrivateKeyword */: case 122 /* ProtectedKeyword */: - case 143 /* ReadonlyKeyword */: + case 144 /* ReadonlyKeyword */: case 126 /* AbstractKeyword */: - case 134 /* DeclareKeyword */: + case 135 /* 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 130 /* AnyKeyword */: + case 146 /* NumberKeyword */: + case 157 /* BigIntKeyword */: + case 143 /* NeverKeyword */: + case 147 /* ObjectKeyword */: + case 158 /* OverrideKeyword */: + case 149 /* StringKeyword */: + case 133 /* BooleanKeyword */: + case 150 /* SymbolKeyword */: case 114 /* VoidKeyword */: - case 153 /* UnknownKeyword */: - case 151 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + case 154 /* UnknownKeyword */: + case 152 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. transformFlags = 1 /* ContainsTypeScript */; break; case 106 /* SuperKeyword */: @@ -22310,42 +22419,30 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) { + if (flags & 1 /* Export */) result.push(createModifier(93 /* ExportKeyword */)); - } - if (flags & 2 /* Ambient */) { - result.push(createModifier(134 /* DeclareKeyword */)); - } - if (flags & 512 /* Default */) { + if (flags & 2 /* Ambient */) + result.push(createModifier(135 /* DeclareKeyword */)); + if (flags & 512 /* Default */) result.push(createModifier(88 /* DefaultKeyword */)); - } - if (flags & 2048 /* Const */) { + if (flags & 2048 /* Const */) result.push(createModifier(85 /* ConstKeyword */)); - } - if (flags & 4 /* Public */) { + if (flags & 4 /* Public */) result.push(createModifier(123 /* PublicKeyword */)); - } - if (flags & 8 /* Private */) { + if (flags & 8 /* Private */) result.push(createModifier(121 /* PrivateKeyword */)); - } - if (flags & 16 /* Protected */) { + if (flags & 16 /* Protected */) result.push(createModifier(122 /* ProtectedKeyword */)); - } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* Abstract */) result.push(createModifier(126 /* AbstractKeyword */)); - } - if (flags & 32 /* Static */) { + if (flags & 32 /* Static */) result.push(createModifier(124 /* StaticKeyword */)); - } - if (flags & 16384 /* Override */) { - result.push(createModifier(157 /* OverrideKeyword */)); - } - if (flags & 64 /* Readonly */) { - result.push(createModifier(143 /* ReadonlyKeyword */)); - } - if (flags & 256 /* Async */) { - result.push(createModifier(130 /* AsyncKeyword */)); - } + if (flags & 16384 /* Override */) + result.push(createModifier(158 /* OverrideKeyword */)); + if (flags & 64 /* Readonly */) + result.push(createModifier(144 /* ReadonlyKeyword */)); + if (flags & 256 /* Async */) + result.push(createModifier(131 /* AsyncKeyword */)); return result; } // @@ -22353,7 +22450,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(159 /* QualifiedName */); + var node = createBaseNode(160 /* QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -22370,7 +22467,7 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(160 /* ComputedPropertyName */); + var node = createBaseNode(161 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -22389,7 +22486,7 @@ var ts; // // @api function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createBaseNamedDeclaration(161 /* TypeParameter */, + var node = createBaseNamedDeclaration(162 /* TypeParameter */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.constraint = constraint; @@ -22407,7 +22504,7 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(162 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(163 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -22440,7 +22537,7 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(163 /* Decorator */); + var node = createBaseNode(164 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -22459,7 +22556,7 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(164 /* PropertySignature */, + var node = createBaseNamedDeclaration(165 /* PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; @@ -22477,7 +22574,7 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(165 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(166 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= @@ -22506,7 +22603,7 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(166 /* MethodSignature */, + var node = createBaseSignatureDeclaration(167 /* MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1 /* ContainsTypeScript */; @@ -22525,7 +22622,7 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(167 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(168 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= @@ -22564,7 +22661,7 @@ var ts; } // @api function createClassStaticBlockDeclaration(decorators, modifiers, body) { - var node = createBaseGenericNamedDeclaration(168 /* ClassStaticBlockDeclaration */, decorators, modifiers, + var node = createBaseGenericNamedDeclaration(169 /* ClassStaticBlockDeclaration */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; @@ -22581,7 +22678,7 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(169 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(170 /* Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); @@ -22599,7 +22696,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(170 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(171 /* GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -22615,7 +22712,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(171 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(172 /* SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -22631,7 +22728,7 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(172 /* CallSignature */, + var node = createBaseSignatureDeclaration(173 /* CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -22648,7 +22745,7 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(173 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(174 /* ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -22665,7 +22762,7 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(175 /* IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22682,7 +22779,7 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(197 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(198 /* TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; @@ -22704,7 +22801,7 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(175 /* TypePredicate */); + var node = createBaseNode(176 /* TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; @@ -22721,7 +22818,7 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(176 /* TypeReference */); + var node = createBaseNode(177 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22736,7 +22833,7 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(177 /* FunctionType */, + var node = createBaseSignatureDeclaration(178 /* FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -22762,7 +22859,7 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(178 /* ConstructorType */, + var node = createBaseSignatureDeclaration(179 /* ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22796,7 +22893,7 @@ var ts; } // @api function createTypeQueryNode(exprName) { - var node = createBaseNode(179 /* TypeQuery */); + var node = createBaseNode(180 /* TypeQuery */); node.exprName = exprName; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22809,7 +22906,7 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(180 /* TypeLiteral */); + var node = createBaseNode(181 /* TypeLiteral */); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22822,7 +22919,7 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(181 /* ArrayType */); + var node = createBaseNode(182 /* ArrayType */); node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22835,7 +22932,7 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(182 /* TupleType */); + var node = createBaseNode(183 /* TupleType */); node.elements = createNodeArray(elements); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22848,7 +22945,7 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(195 /* NamedTupleMember */); + var node = createBaseNode(196 /* NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; @@ -22867,7 +22964,7 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(183 /* OptionalType */); + var node = createBaseNode(184 /* OptionalType */); node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22880,7 +22977,7 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(184 /* RestType */); + var node = createBaseNode(185 /* RestType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22904,7 +23001,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(185 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(186 /* UnionType */, types); } // @api function updateUnionTypeNode(node, types) { @@ -22912,7 +23009,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(186 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(187 /* IntersectionType */, types); } // @api function updateIntersectionTypeNode(node, types) { @@ -22920,7 +23017,7 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(187 /* ConditionalType */); + var node = createBaseNode(188 /* ConditionalType */); node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType); node.trueType = trueType; @@ -22939,7 +23036,7 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(188 /* InferType */); + var node = createBaseNode(189 /* InferType */); node.typeParameter = typeParameter; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22952,7 +23049,7 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(196 /* TemplateLiteralType */); + var node = createBaseNode(197 /* TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22968,7 +23065,7 @@ var ts; // @api function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(198 /* ImportType */); + var node = createBaseNode(199 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); @@ -22988,7 +23085,7 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(189 /* ParenthesizedType */); + var node = createBaseNode(190 /* ParenthesizedType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23001,13 +23098,13 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(190 /* ThisType */); + var node = createBaseNode(191 /* ThisType */); node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(191 /* TypeOperator */); + var node = createBaseNode(192 /* TypeOperator */); node.operator = operator; node.type = parenthesizerRules().parenthesizeMemberOfElementType(type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -23021,7 +23118,7 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(192 /* IndexedAccessType */); + var node = createBaseNode(193 /* IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType); node.indexType = indexType; node.transformFlags = 1 /* ContainsTypeScript */; @@ -23035,29 +23132,31 @@ var ts; : node; } // @api - function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { - var node = createBaseNode(193 /* MappedType */); + function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { + var node = createBaseNode(194 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; + node.members = members && createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api - function updateMappedTypeNode(node, readonlyToken, typeParameter, nameType, questionToken, type) { + function updateMappedTypeNode(node, readonlyToken, typeParameter, nameType, questionToken, type, members) { return node.readonlyToken !== readonlyToken || node.typeParameter !== typeParameter || node.nameType !== nameType || node.questionToken !== questionToken || node.type !== type - ? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), node) + || node.members !== members + ? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), node) : node; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(194 /* LiteralType */); + var node = createBaseNode(195 /* LiteralType */); node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23073,7 +23172,7 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(199 /* ObjectBindingPattern */); + var node = createBaseNode(200 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | @@ -23094,7 +23193,7 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(200 /* ArrayBindingPattern */); + var node = createBaseNode(201 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | @@ -23110,7 +23209,7 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(201 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(202 /* BindingElement */, /*decorators*/ undefined, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); @@ -23146,7 +23245,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(202 /* ArrayLiteralExpression */); + var node = createBaseExpression(203 /* 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. @@ -23165,7 +23264,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(203 /* ObjectLiteralExpression */); + var node = createBaseExpression(204 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -23179,7 +23278,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(204 /* PropertyAccessExpression */); + var node = createBaseExpression(205 /* PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -23208,7 +23307,7 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(204 /* PropertyAccessExpression */); + var node = createBaseExpression(205 /* PropertyAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -23235,7 +23334,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(205 /* ElementAccessExpression */); + var node = createBaseExpression(206 /* ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -23262,7 +23361,7 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(205 /* ElementAccessExpression */); + var node = createBaseExpression(206 /* ElementAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -23287,7 +23386,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(206 /* CallExpression */); + var node = createBaseExpression(207 /* CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -23319,7 +23418,7 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(206 /* CallExpression */); + var node = createBaseExpression(207 /* CallExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -23351,7 +23450,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(207 /* NewExpression */); + var node = createBaseExpression(208 /* NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -23375,7 +23474,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(208 /* TaggedTemplateExpression */); + var node = createBaseExpression(209 /* TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -23402,7 +23501,7 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(209 /* TypeAssertionExpression */); + var node = createBaseExpression(210 /* TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= @@ -23420,7 +23519,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(210 /* ParenthesizedExpression */); + var node = createBaseExpression(211 /* ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -23433,7 +23532,7 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(211 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(212 /* FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); @@ -23467,7 +23566,7 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(212 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(213 /* ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); @@ -23492,7 +23591,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(213 /* DeleteExpression */); + var node = createBaseExpression(214 /* DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23505,7 +23604,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(214 /* TypeOfExpression */); + var node = createBaseExpression(215 /* TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23518,7 +23617,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(215 /* VoidExpression */); + var node = createBaseExpression(216 /* VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23531,7 +23630,7 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(216 /* AwaitExpression */); + var node = createBaseExpression(217 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -23548,7 +23647,7 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(217 /* PrefixUnaryExpression */); + var node = createBaseExpression(218 /* PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -23570,7 +23669,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(218 /* PostfixUnaryExpression */); + var node = createBaseExpression(219 /* PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -23591,7 +23690,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(219 /* BinaryExpression */); + var node = createBaseExpression(220 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -23660,7 +23759,7 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(220 /* ConditionalExpression */); + var node = createBaseExpression(221 /* ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); @@ -23686,7 +23785,7 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(221 /* TemplateExpression */); + var node = createBaseExpression(222 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= @@ -23756,7 +23855,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(222 /* YieldExpression */); + var node = createBaseExpression(223 /* YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= @@ -23776,7 +23875,7 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(223 /* SpreadElement */); + var node = createBaseExpression(224 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -23792,7 +23891,7 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(224 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(225 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); node.transformFlags |= 512 /* ContainsES2015 */; return node; } @@ -23809,11 +23908,11 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(225 /* OmittedExpression */); + return createBaseExpression(226 /* OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(226 /* ExpressionWithTypeArguments */); + var node = createBaseNode(227 /* ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= @@ -23831,7 +23930,7 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(227 /* AsExpression */); + var node = createBaseExpression(228 /* AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= @@ -23849,7 +23948,7 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(228 /* NonNullExpression */); + var node = createBaseExpression(229 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -23867,7 +23966,7 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(228 /* NonNullExpression */); + var node = createBaseExpression(229 /* NonNullExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= @@ -23884,7 +23983,7 @@ var ts; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(229 /* MetaProperty */); + var node = createBaseExpression(230 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); @@ -23911,7 +24010,7 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(231 /* TemplateSpan */); + var node = createBaseNode(232 /* TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= @@ -23929,7 +24028,7 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(232 /* SemicolonClassElement */); + var node = createBaseNode(233 /* SemicolonClassElement */); node.transformFlags |= 512 /* ContainsES2015 */; return node; } @@ -23938,7 +24037,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(233 /* Block */); + var node = createBaseNode(234 /* Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -23952,7 +24051,7 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(235 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(236 /* VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); @@ -23970,11 +24069,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(234 /* EmptyStatement */); + return createBaseNode(235 /* EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(236 /* ExpressionStatement */); + var node = createBaseNode(237 /* ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23987,7 +24086,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(237 /* IfStatement */); + var node = createBaseNode(238 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -24007,7 +24106,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(238 /* DoStatement */); + var node = createBaseNode(239 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -24024,7 +24123,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(239 /* WhileStatement */); + var node = createBaseNode(240 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24041,7 +24140,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(240 /* ForStatement */); + var node = createBaseNode(241 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -24064,7 +24163,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(241 /* ForInStatement */); + var node = createBaseNode(242 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -24084,7 +24183,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(242 /* ForOfStatement */); + var node = createBaseNode(243 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -24110,7 +24209,7 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(243 /* ContinueStatement */); + var node = createBaseNode(244 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | @@ -24125,7 +24224,7 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(244 /* BreakStatement */); + var node = createBaseNode(245 /* BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | @@ -24140,7 +24239,7 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(245 /* ReturnStatement */); + var node = createBaseNode(246 /* ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= @@ -24157,7 +24256,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(246 /* WithStatement */); + var node = createBaseNode(247 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24174,7 +24273,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(247 /* SwitchStatement */); + var node = createBaseNode(248 /* SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -24191,7 +24290,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(248 /* LabeledStatement */); + var node = createBaseNode(249 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24208,7 +24307,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(249 /* ThrowStatement */); + var node = createBaseNode(250 /* ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24221,7 +24320,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(250 /* TryStatement */); + var node = createBaseNode(251 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -24241,11 +24340,11 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(251 /* DebuggerStatement */); + return createBaseNode(252 /* DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(252 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(253 /* VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; @@ -24267,7 +24366,7 @@ var ts; // @api function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(253 /* VariableDeclarationList */); + var node = createBaseNode(254 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= @@ -24288,7 +24387,7 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(254 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(255 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; @@ -24326,7 +24425,7 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(255 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(256 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } @@ -24351,7 +24450,7 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(256 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(257 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -24369,7 +24468,7 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(257 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(258 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -24386,7 +24485,7 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(258 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(259 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | @@ -24406,7 +24505,7 @@ var ts; // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(259 /* ModuleDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(260 /* ModuleDeclaration */, decorators, modifiers); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.name = name; node.body = body; @@ -24433,7 +24532,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(260 /* ModuleBlock */); + var node = createBaseNode(261 /* ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -24446,7 +24545,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(261 /* CaseBlock */); + var node = createBaseNode(262 /* CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -24459,7 +24558,7 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(262 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(263 /* NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.transformFlags = 1 /* ContainsTypeScript */; @@ -24473,7 +24572,7 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(263 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(264 /* ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); @@ -24493,10 +24592,11 @@ var ts; : node; } // @api - function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createBaseDeclaration(264 /* ImportDeclaration */, decorators, modifiers); + function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause) { + var node = createBaseDeclaration(265 /* ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; + node.assertClause = assertClause; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); @@ -24504,17 +24604,18 @@ var ts; return node; } // @api - function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) { + function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier, assertClause) { return node.decorators !== decorators || node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier - ? update(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) + || node.assertClause !== assertClause + ? update(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause), node) : node; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(265 /* ImportClause */); + var node = createBaseNode(266 /* ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -24536,8 +24637,38 @@ var ts; : node; } // @api + function createAssertClause(elements, multiLine) { + var node = createBaseNode(292 /* AssertClause */); + node.elements = elements; + node.multiLine = multiLine; + node.transformFlags |= 4 /* ContainsESNext */; + return node; + } + // @api + function updateAssertClause(node, elements, multiLine) { + return node.elements !== elements + || node.multiLine !== multiLine + ? update(createAssertClause(elements, multiLine), node) + : node; + } + // @api + function createAssertEntry(name, value) { + var node = createBaseNode(293 /* AssertEntry */); + node.name = name; + node.value = value; + node.transformFlags |= 4 /* ContainsESNext */; + return node; + } + // @api + function updateAssertEntry(node, name, value) { + return node.name !== name + || node.value !== value + ? update(createAssertEntry(name, value), node) + : node; + } + // @api function createNamespaceImport(name) { - var node = createBaseNode(266 /* NamespaceImport */); + var node = createBaseNode(267 /* NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -24551,7 +24682,7 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(272 /* NamespaceExport */); + var node = createBaseNode(273 /* NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | @@ -24567,7 +24698,7 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(267 /* NamedImports */); + var node = createBaseNode(268 /* NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -24580,8 +24711,9 @@ var ts; : node; } // @api - function createImportSpecifier(propertyName, name) { - var node = createBaseNode(268 /* ImportSpecifier */); + function createImportSpecifier(isTypeOnly, propertyName, name) { + var node = createBaseNode(269 /* ImportSpecifier */); + node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= @@ -24591,15 +24723,16 @@ var ts; return node; } // @api - function updateImportSpecifier(node, propertyName, name) { - return node.propertyName !== propertyName + function updateImportSpecifier(node, isTypeOnly, propertyName, name) { + return node.isTypeOnly !== isTypeOnly + || node.propertyName !== propertyName || node.name !== name - ? update(createImportSpecifier(propertyName, name), node) + ? update(createImportSpecifier(isTypeOnly, propertyName, name), node) : node; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(269 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(270 /* ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) @@ -24617,11 +24750,12 @@ var ts; : node; } // @api - function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { - var node = createBaseDeclaration(270 /* ExportDeclaration */, decorators, modifiers); + function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { + var node = createBaseDeclaration(271 /* ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; + node.assertClause = assertClause; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); @@ -24629,18 +24763,19 @@ var ts; return node; } // @api - function updateExportDeclaration(node, decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { + function updateExportDeclaration(node, decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { return node.decorators !== decorators || node.modifiers !== modifiers || node.isTypeOnly !== isTypeOnly || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier - ? update(createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier), node) + || node.assertClause !== assertClause + ? update(createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause), node) : node; } // @api function createNamedExports(elements) { - var node = createBaseNode(271 /* NamedExports */); + var node = createBaseNode(272 /* NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -24653,8 +24788,9 @@ var ts; : node; } // @api - function createExportSpecifier(propertyName, name) { - var node = createBaseNode(273 /* ExportSpecifier */); + function createExportSpecifier(isTypeOnly, propertyName, name) { + var node = createBaseNode(274 /* ExportSpecifier */); + node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= @@ -24664,15 +24800,16 @@ var ts; return node; } // @api - function updateExportSpecifier(node, propertyName, name) { - return node.propertyName !== propertyName + function updateExportSpecifier(node, isTypeOnly, propertyName, name) { + return node.isTypeOnly !== isTypeOnly + || node.propertyName !== propertyName || node.name !== name - ? update(createExportSpecifier(propertyName, name), node) + ? update(createExportSpecifier(isTypeOnly, propertyName, name), node) : node; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(274 /* MissingDeclaration */, + var node = createBaseDeclaration(275 /* MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -24682,7 +24819,7 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(275 /* ExternalModuleReference */); + var node = createBaseNode(276 /* ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context @@ -24727,7 +24864,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(312 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(315 /* JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -24744,7 +24881,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(317 /* JSDocTypeLiteral */); + var node = createBaseNode(320 /* JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -24758,7 +24895,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(304 /* JSDocTypeExpression */); + var node = createBaseNode(307 /* JSDocTypeExpression */); node.type = type; return node; } @@ -24770,7 +24907,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(318 /* JSDocSignature */); + var node = createBaseNode(321 /* JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -24799,7 +24936,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(339 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(342 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -24816,7 +24953,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(340 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(343 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -24834,7 +24971,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(335 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(338 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -24855,7 +24992,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(342 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(345 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -24876,7 +25013,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(333 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(336 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -24894,7 +25031,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(323 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(326 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -24909,13 +25046,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(324 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(327 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(341 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(344 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -24929,7 +25066,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(305 /* JSDocNameReference */); + var node = createBaseNode(308 /* JSDocNameReference */); node.name = name; return node; } @@ -24941,7 +25078,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(306 /* JSDocMemberName */); + var node = createBaseNode(309 /* JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -24958,7 +25095,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(319 /* JSDocLink */); + var node = createBaseNode(322 /* JSDocLink */); node.name = name; node.text = text; return node; @@ -24971,7 +25108,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(320 /* JSDocLinkCode */); + var node = createBaseNode(323 /* JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -24984,7 +25121,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(321 /* JSDocLinkPlain */); + var node = createBaseNode(324 /* JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -25056,7 +25193,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(322 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(325 /* JSDocTag */, tagName, comment); return node; } // @api @@ -25068,7 +25205,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(316 /* JSDocText */); + var node = createBaseNode(319 /* JSDocText */); node.text = text; return node; } @@ -25080,7 +25217,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(315 /* JSDocComment */); + var node = createBaseNode(318 /* JSDocComment */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -25097,7 +25234,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(276 /* JsxElement */); + var node = createBaseNode(277 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -25118,7 +25255,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(277 /* JsxSelfClosingElement */); + var node = createBaseNode(278 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25142,7 +25279,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(278 /* JsxOpeningElement */); + var node = createBaseNode(279 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -25166,7 +25303,7 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(279 /* JsxClosingElement */); + var node = createBaseNode(280 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | @@ -25181,7 +25318,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(280 /* JsxFragment */); + var node = createBaseNode(281 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -25217,19 +25354,19 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(281 /* JsxOpeningFragment */); + var node = createBaseNode(282 /* JsxOpeningFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(282 /* JsxClosingFragment */); + var node = createBaseNode(283 /* JsxClosingFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(283 /* JsxAttribute */); + var node = createBaseNode(284 /* JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= @@ -25247,7 +25384,7 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(284 /* JsxAttributes */); + var node = createBaseNode(285 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | @@ -25262,7 +25399,7 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(285 /* JsxSpreadAttribute */); + var node = createBaseNode(286 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | @@ -25277,7 +25414,7 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(286 /* JsxExpression */); + var node = createBaseNode(287 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= @@ -25297,7 +25434,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(287 /* CaseClause */); + var node = createBaseNode(288 /* CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -25314,7 +25451,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(288 /* DefaultClause */); + var node = createBaseNode(289 /* DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -25327,7 +25464,7 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(289 /* HeritageClause */); + var node = createBaseNode(290 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); @@ -25351,11 +25488,13 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(290 /* CatchClause */); - variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, - /*exclamationToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined); + var node = createBaseNode(291 /* CatchClause */); + if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { + variableDeclaration = createVariableDeclaration(variableDeclaration, + /*exclamationToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined); + } node.variableDeclaration = variableDeclaration; node.block = block; node.transformFlags |= @@ -25377,7 +25516,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(291 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(294 /* PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -25407,7 +25546,7 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(292 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(295 /* ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); @@ -25439,7 +25578,7 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(293 /* SpreadAssignment */); + var node = createBaseNode(296 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -25458,7 +25597,7 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(294 /* EnumMember */); + var node = createBaseNode(297 /* EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -25479,7 +25618,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(300 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(303 /* SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -25496,7 +25635,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(300 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(303 /* SourceFile */); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -25513,6 +25652,7 @@ var ts; node.transformFlags = propagateChildrenFlags(node.statements) | propagateChildFlags(node.endOfFileToken); + node.impliedNodeFormat = source.impliedNodeFormat; return node; } // @api @@ -25534,7 +25674,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(301 /* Bundle */); + var node = createBaseNode(304 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -25549,7 +25689,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(302 /* UnparsedSource */); + var node = createBaseNode(305 /* UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -25567,28 +25707,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(295 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(298 /* UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(296 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(299 /* UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 298 /* UnparsedInternalText */ : 297 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 301 /* UnparsedInternalText */ : 300 /* UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(299 /* UnparsedSyntheticReference */); + var node = createBaseNode(302 /* UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(303 /* InputFiles */); + var node = createBaseNode(306 /* InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -25599,7 +25739,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(230 /* SyntheticExpression */); + var node = createBaseNode(231 /* SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -25607,7 +25747,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(343 /* SyntaxList */); + var node = createBaseNode(346 /* SyntaxList */); node._children = children; return node; } @@ -25622,7 +25762,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(344 /* NotEmittedStatement */); + var node = createBaseNode(347 /* NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -25636,7 +25776,7 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(345 /* PartiallyEmittedExpression */); + var node = createBaseNode(348 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= @@ -25664,7 +25804,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(346 /* CommaListExpression */); + var node = createBaseNode(349 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -25681,7 +25821,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(348 /* EndOfDeclarationMarker */); + var node = createBaseNode(351 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -25692,14 +25832,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(347 /* MergeDeclarationMarker */); + var node = createBaseNode(350 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(349 /* SyntheticReferenceExpression */); + var node = createBaseNode(352 /* SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -25721,7 +25861,7 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(300 /* SourceFile */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(303 /* SourceFile */) : ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : @@ -25772,7 +25912,7 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, createNamedExports([ - createExportSpecifier(/*propertyName*/ undefined, exportName) + createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, exportName) ])); } // @@ -25840,11 +25980,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - 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); + case 211 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 210 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 228 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 229 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 348 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -25898,13 +26038,13 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -26283,9 +26423,9 @@ var ts; ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifiers, node.name, node.members) : ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifiers, node.name, node.body) : ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.name, node.moduleReference) : - ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifiers, node.importClause, node.moduleSpecifier) : + ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifiers, node.importClause, node.moduleSpecifier, node.assertClause) : ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifiers, node.expression) : - ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier) : + ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) : ts.Debug.assertNever(node); } function asNodeArray(array) { @@ -26324,24 +26464,24 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - 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"; + case 341 /* JSDocTypeTag */: return "type"; + case 339 /* JSDocReturnTag */: return "returns"; + case 340 /* JSDocThisTag */: return "this"; + case 337 /* JSDocEnumTag */: return "enum"; + case 328 /* JSDocAuthorTag */: return "author"; + case 330 /* JSDocClassTag */: return "class"; + case 331 /* JSDocPublicTag */: return "public"; + case 332 /* JSDocPrivateTag */: return "private"; + case 333 /* JSDocProtectedTag */: return "protected"; + case 334 /* JSDocReadonlyTag */: return "readonly"; + case 335 /* JSDocOverrideTag */: return "override"; + case 342 /* JSDocTemplateTag */: return "template"; + case 343 /* JSDocTypedefTag */: return "typedef"; + case 338 /* JSDocParameterTag */: return "param"; + case 345 /* JSDocPropertyTag */: return "prop"; + case 336 /* JSDocCallbackTag */: return "callback"; + case 326 /* JSDocAugmentsTag */: return "augments"; + case 327 /* JSDocImplementsTag */: return "implements"; default: return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); } @@ -26421,69 +26561,69 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 175 /* FirstTypeNode */ && kind <= 198 /* LastTypeNode */) { + if (kind >= 176 /* FirstTypeNode */ && kind <= 199 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 206 /* CallExpression */: - case 207 /* NewExpression */: - case 202 /* ArrayLiteralExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: + case 203 /* ArrayLiteralExpression */: return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return 589443072 /* ModuleExcludes */; - case 162 /* Parameter */: + case 163 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return 557748224 /* ArrowFunctionExcludes */; - case 211 /* FunctionExpression */: - case 254 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: return 591310848 /* FunctionExcludes */; - case 253 /* VariableDeclarationList */: + case 254 /* VariableDeclarationList */: return 537165824 /* VariableDeclarationListExcludes */; - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: return 536940544 /* ClassExcludes */; - case 169 /* Constructor */: + case 170 /* Constructor */: return 591306752 /* ConstructorExcludes */; - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return 570433536 /* PropertyExcludes */; - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* 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 130 /* AnyKeyword */: + case 146 /* NumberKeyword */: + case 157 /* BigIntKeyword */: + case 143 /* NeverKeyword */: + case 149 /* StringKeyword */: + case 147 /* ObjectKeyword */: + case 133 /* BooleanKeyword */: + case 150 /* 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 */: + case 162 /* TypeParameter */: + case 165 /* PropertySignature */: + case 167 /* MethodSignature */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 175 /* IndexSignature */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return 536973312 /* ObjectLiteralExcludes */; - case 290 /* CatchClause */: + case 291 /* CatchClause */: return 536903680 /* CatchClauseExcludes */; - case 199 /* ObjectBindingPattern */: - case 200 /* ArrayBindingPattern */: + case 200 /* ObjectBindingPattern */: + case 201 /* ArrayBindingPattern */: return 536887296 /* BindingPatternExcludes */; - case 209 /* TypeAssertionExpression */: - case 227 /* AsExpression */: - case 345 /* PartiallyEmittedExpression */: - case 210 /* ParenthesizedExpression */: + case 210 /* TypeAssertionExpression */: + case 228 /* AsExpression */: + case 348 /* PartiallyEmittedExpression */: + case 211 /* ParenthesizedExpression */: case 106 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -26782,7 +26922,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 === 300 /* SourceFile */) { + if (node.kind === 303 /* 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."); @@ -27038,6 +27178,25 @@ var ts; } } ts.moveEmitHelpers = moveEmitHelpers; + /** + * Gets the SnippetElement of a node. + */ + /* @internal */ + function getSnippetElement(node) { + var _a; + return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.snippetElement; + } + ts.getSnippetElement = getSnippetElement; + /** + * Sets the SnippetElement of a node. + */ + /* @internal */ + function setSnippetElement(node, snippet) { + var emitNode = getOrCreateEmitNode(node); + emitNode.snippetElement = snippet; + return node; + } + ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; @@ -27086,6 +27245,7 @@ var ts; // Class Fields Helpers createClassPrivateFieldGetHelper: createClassPrivateFieldGetHelper, createClassPrivateFieldSetHelper: createClassPrivateFieldSetHelper, + createClassPrivateFieldInHelper: createClassPrivateFieldInHelper }; /** * Gets an identifier for the name of an *unscoped* emit helper. @@ -27126,7 +27286,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (context.getCompilerOptions().target >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -27296,6 +27456,10 @@ var ts; } return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args); } + function createClassPrivateFieldInHelper(state, receiver) { + context.requestEmitHelper(ts.classPrivateFieldInHelper); + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldIn"), /* typeArguments*/ undefined, [state, receiver]); + } } ts.createEmitHelperFactory = createEmitHelperFactory; /* @internal */ @@ -27653,6 +27817,24 @@ var ts; scoped: false, text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n };" }; + /** + * Parameters: + * @param state — One of the following: + * - A WeakMap when the member is a private instance field. + * - A WeakSet when the member is a private instance method or accessor. + * - A function value that should be the undecorated class constructor when the member is a private static field, method, or accessor. + * @param receiver — The object being checked if it has the private member. + * + * Usage: + * This helper is used to transform `#field in expression` to + * `__classPrivateFieldIn(, expression)` + */ + ts.classPrivateFieldInHelper = { + name: "typescript:classPrivateFieldIn", + importName: "__classPrivateFieldIn", + scoped: false, + text: "\n var __classPrivateFieldIn = (this && this.__classPrivateFieldIn) || function(state, receiver) {\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\n };" + }; var allUnscopedEmitHelpers; function getAllUnscopedEmitHelpers() { return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([ @@ -27677,6 +27859,7 @@ var ts; ts.exportStarHelper, ts.classPrivateFieldGetHelper, ts.classPrivateFieldSetHelper, + ts.classPrivateFieldInHelper, ts.createBindingHelper, ts.setModuleDefaultHelper ], function (helper) { return helper.name; })); @@ -27804,7 +27987,7 @@ var ts; ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 130 /* AsyncKeyword */; + return node.kind === 131 /* AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ @@ -27814,12 +27997,12 @@ var ts; ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 131 /* AwaitKeyword */; + return node.kind === 132 /* AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 143 /* ReadonlyKeyword */; + return node.kind === 144 /* ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ @@ -27844,593 +28027,601 @@ var ts; ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 159 /* QualifiedName */; + return node.kind === 160 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 160 /* ComputedPropertyName */; + return node.kind === 161 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 161 /* TypeParameter */; + return node.kind === 162 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 162 /* Parameter */; + return node.kind === 163 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 163 /* Decorator */; + return node.kind === 164 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 164 /* PropertySignature */; + return node.kind === 165 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 165 /* PropertyDeclaration */; + return node.kind === 166 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 166 /* MethodSignature */; + return node.kind === 167 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 167 /* MethodDeclaration */; + return node.kind === 168 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 168 /* ClassStaticBlockDeclaration */; + return node.kind === 169 /* ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 169 /* Constructor */; + return node.kind === 170 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 170 /* GetAccessor */; + return node.kind === 171 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 171 /* SetAccessor */; + return node.kind === 172 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 172 /* CallSignature */; + return node.kind === 173 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 173 /* ConstructSignature */; + return node.kind === 174 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 174 /* IndexSignature */; + return node.kind === 175 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 175 /* TypePredicate */; + return node.kind === 176 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 176 /* TypeReference */; + return node.kind === 177 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 177 /* FunctionType */; + return node.kind === 178 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 178 /* ConstructorType */; + return node.kind === 179 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 179 /* TypeQuery */; + return node.kind === 180 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 180 /* TypeLiteral */; + return node.kind === 181 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 181 /* ArrayType */; + return node.kind === 182 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 182 /* TupleType */; + return node.kind === 183 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 195 /* NamedTupleMember */; + return node.kind === 196 /* NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 183 /* OptionalType */; + return node.kind === 184 /* OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 184 /* RestType */; + return node.kind === 185 /* RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 185 /* UnionType */; + return node.kind === 186 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 186 /* IntersectionType */; + return node.kind === 187 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 187 /* ConditionalType */; + return node.kind === 188 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 188 /* InferType */; + return node.kind === 189 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 189 /* ParenthesizedType */; + return node.kind === 190 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 190 /* ThisType */; + return node.kind === 191 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 191 /* TypeOperator */; + return node.kind === 192 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 192 /* IndexedAccessType */; + return node.kind === 193 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 193 /* MappedType */; + return node.kind === 194 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 194 /* LiteralType */; + return node.kind === 195 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 198 /* ImportType */; + return node.kind === 199 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 197 /* TemplateLiteralTypeSpan */; + return node.kind === 198 /* TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 196 /* TemplateLiteralType */; + return node.kind === 197 /* TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 199 /* ObjectBindingPattern */; + return node.kind === 200 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 200 /* ArrayBindingPattern */; + return node.kind === 201 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 201 /* BindingElement */; + return node.kind === 202 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 202 /* ArrayLiteralExpression */; + return node.kind === 203 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 203 /* ObjectLiteralExpression */; + return node.kind === 204 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 204 /* PropertyAccessExpression */; + return node.kind === 205 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 205 /* ElementAccessExpression */; + return node.kind === 206 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 206 /* CallExpression */; + return node.kind === 207 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 207 /* NewExpression */; + return node.kind === 208 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 208 /* TaggedTemplateExpression */; + return node.kind === 209 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 209 /* TypeAssertionExpression */; + return node.kind === 210 /* TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 210 /* ParenthesizedExpression */; + return node.kind === 211 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 211 /* FunctionExpression */; + return node.kind === 212 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 212 /* ArrowFunction */; + return node.kind === 213 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 213 /* DeleteExpression */; + return node.kind === 214 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 214 /* TypeOfExpression */; + return node.kind === 215 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 215 /* VoidExpression */; + return node.kind === 216 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 216 /* AwaitExpression */; + return node.kind === 217 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 217 /* PrefixUnaryExpression */; + return node.kind === 218 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 218 /* PostfixUnaryExpression */; + return node.kind === 219 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 219 /* BinaryExpression */; + return node.kind === 220 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 220 /* ConditionalExpression */; + return node.kind === 221 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 221 /* TemplateExpression */; + return node.kind === 222 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 222 /* YieldExpression */; + return node.kind === 223 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 223 /* SpreadElement */; + return node.kind === 224 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 224 /* ClassExpression */; + return node.kind === 225 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 225 /* OmittedExpression */; + return node.kind === 226 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 226 /* ExpressionWithTypeArguments */; + return node.kind === 227 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 227 /* AsExpression */; + return node.kind === 228 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 228 /* NonNullExpression */; + return node.kind === 229 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 229 /* MetaProperty */; + return node.kind === 230 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 230 /* SyntheticExpression */; + return node.kind === 231 /* SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 345 /* PartiallyEmittedExpression */; + return node.kind === 348 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 346 /* CommaListExpression */; + return node.kind === 349 /* CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 231 /* TemplateSpan */; + return node.kind === 232 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 232 /* SemicolonClassElement */; + return node.kind === 233 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 233 /* Block */; + return node.kind === 234 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 235 /* VariableStatement */; + return node.kind === 236 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 234 /* EmptyStatement */; + return node.kind === 235 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 236 /* ExpressionStatement */; + return node.kind === 237 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 237 /* IfStatement */; + return node.kind === 238 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 238 /* DoStatement */; + return node.kind === 239 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 239 /* WhileStatement */; + return node.kind === 240 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 240 /* ForStatement */; + return node.kind === 241 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 241 /* ForInStatement */; + return node.kind === 242 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 242 /* ForOfStatement */; + return node.kind === 243 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 243 /* ContinueStatement */; + return node.kind === 244 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 244 /* BreakStatement */; + return node.kind === 245 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 245 /* ReturnStatement */; + return node.kind === 246 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 246 /* WithStatement */; + return node.kind === 247 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 247 /* SwitchStatement */; + return node.kind === 248 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 248 /* LabeledStatement */; + return node.kind === 249 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 249 /* ThrowStatement */; + return node.kind === 250 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 250 /* TryStatement */; + return node.kind === 251 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 251 /* DebuggerStatement */; + return node.kind === 252 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 252 /* VariableDeclaration */; + return node.kind === 253 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 253 /* VariableDeclarationList */; + return node.kind === 254 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 254 /* FunctionDeclaration */; + return node.kind === 255 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 255 /* ClassDeclaration */; + return node.kind === 256 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 256 /* InterfaceDeclaration */; + return node.kind === 257 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 257 /* TypeAliasDeclaration */; + return node.kind === 258 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 258 /* EnumDeclaration */; + return node.kind === 259 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 259 /* ModuleDeclaration */; + return node.kind === 260 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 260 /* ModuleBlock */; + return node.kind === 261 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 261 /* CaseBlock */; + return node.kind === 262 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 262 /* NamespaceExportDeclaration */; + return node.kind === 263 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 263 /* ImportEqualsDeclaration */; + return node.kind === 264 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 264 /* ImportDeclaration */; + return node.kind === 265 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 265 /* ImportClause */; + return node.kind === 266 /* ImportClause */; } ts.isImportClause = isImportClause; + function isAssertClause(node) { + return node.kind === 292 /* AssertClause */; + } + ts.isAssertClause = isAssertClause; + function isAssertEntry(node) { + return node.kind === 293 /* AssertEntry */; + } + ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 266 /* NamespaceImport */; + return node.kind === 267 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 272 /* NamespaceExport */; + return node.kind === 273 /* NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 267 /* NamedImports */; + return node.kind === 268 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 268 /* ImportSpecifier */; + return node.kind === 269 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 269 /* ExportAssignment */; + return node.kind === 270 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 270 /* ExportDeclaration */; + return node.kind === 271 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 271 /* NamedExports */; + return node.kind === 272 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 273 /* ExportSpecifier */; + return node.kind === 274 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 274 /* MissingDeclaration */; + return node.kind === 275 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 344 /* NotEmittedStatement */; + return node.kind === 347 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 349 /* SyntheticReferenceExpression */; + return node.kind === 352 /* SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 347 /* MergeDeclarationMarker */; + return node.kind === 350 /* MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 348 /* EndOfDeclarationMarker */; + return node.kind === 351 /* EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 275 /* ExternalModuleReference */; + return node.kind === 276 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 276 /* JsxElement */; + return node.kind === 277 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 277 /* JsxSelfClosingElement */; + return node.kind === 278 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 278 /* JsxOpeningElement */; + return node.kind === 279 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 279 /* JsxClosingElement */; + return node.kind === 280 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 280 /* JsxFragment */; + return node.kind === 281 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 281 /* JsxOpeningFragment */; + return node.kind === 282 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 282 /* JsxClosingFragment */; + return node.kind === 283 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 283 /* JsxAttribute */; + return node.kind === 284 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 284 /* JsxAttributes */; + return node.kind === 285 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 285 /* JsxSpreadAttribute */; + return node.kind === 286 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 286 /* JsxExpression */; + return node.kind === 287 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 287 /* CaseClause */; + return node.kind === 288 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 288 /* DefaultClause */; + return node.kind === 289 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 289 /* HeritageClause */; + return node.kind === 290 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 290 /* CatchClause */; + return node.kind === 291 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 291 /* PropertyAssignment */; + return node.kind === 294 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 292 /* ShorthandPropertyAssignment */; + return node.kind === 295 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 293 /* SpreadAssignment */; + return node.kind === 296 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 294 /* EnumMember */; + return node.kind === 297 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 296 /* UnparsedPrepend */; + return node.kind === 299 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -28438,176 +28629,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 300 /* SourceFile */; + return node.kind === 303 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 301 /* Bundle */; + return node.kind === 304 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 302 /* UnparsedSource */; + return node.kind === 305 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 304 /* JSDocTypeExpression */; + return node.kind === 307 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 305 /* JSDocNameReference */; + return node.kind === 308 /* JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 306 /* JSDocMemberName */; + return node.kind === 309 /* JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 319 /* JSDocLink */; + return node.kind === 322 /* JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 320 /* JSDocLinkCode */; + return node.kind === 323 /* JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 321 /* JSDocLinkPlain */; + return node.kind === 324 /* JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 307 /* JSDocAllType */; + return node.kind === 310 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 308 /* JSDocUnknownType */; + return node.kind === 311 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 309 /* JSDocNullableType */; + return node.kind === 312 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 310 /* JSDocNonNullableType */; + return node.kind === 313 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 311 /* JSDocOptionalType */; + return node.kind === 314 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 312 /* JSDocFunctionType */; + return node.kind === 315 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 313 /* JSDocVariadicType */; + return node.kind === 316 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 314 /* JSDocNamepathType */; + return node.kind === 317 /* JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 315 /* JSDocComment */; + return node.kind === 318 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 317 /* JSDocTypeLiteral */; + return node.kind === 320 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 318 /* JSDocSignature */; + return node.kind === 321 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 323 /* JSDocAugmentsTag */; + return node.kind === 326 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 325 /* JSDocAuthorTag */; + return node.kind === 328 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 327 /* JSDocClassTag */; + return node.kind === 330 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 333 /* JSDocCallbackTag */; + return node.kind === 336 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 328 /* JSDocPublicTag */; + return node.kind === 331 /* JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 329 /* JSDocPrivateTag */; + return node.kind === 332 /* JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 330 /* JSDocProtectedTag */; + return node.kind === 333 /* JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 331 /* JSDocReadonlyTag */; + return node.kind === 334 /* JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 332 /* JSDocOverrideTag */; + return node.kind === 335 /* JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 326 /* JSDocDeprecatedTag */; + return node.kind === 329 /* JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 341 /* JSDocSeeTag */; + return node.kind === 344 /* JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 334 /* JSDocEnumTag */; + return node.kind === 337 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 335 /* JSDocParameterTag */; + return node.kind === 338 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 336 /* JSDocReturnTag */; + return node.kind === 339 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 337 /* JSDocThisTag */; + return node.kind === 340 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 338 /* JSDocTypeTag */; + return node.kind === 341 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 339 /* JSDocTemplateTag */; + return node.kind === 342 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 340 /* JSDocTypedefTag */; + return node.kind === 343 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 322 /* JSDocTag */; + return node.kind === 325 /* JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 342 /* JSDocPropertyTag */; + return node.kind === 345 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 324 /* JSDocImplementsTag */; + return node.kind === 327 /* JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 343 /* SyntaxList */; + return n.kind === 346 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -28806,14 +28997,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -28921,21 +29112,36 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 219 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 346 /* CommaListExpression */; + return node.kind === 220 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 349 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; + function isJSDocTypeAssertion(node) { + return ts.isParenthesizedExpression(node) + && ts.isInJSFile(node) + && !!ts.getJSDocTypeTag(node); + } + ts.isJSDocTypeAssertion = isJSDocTypeAssertion; + function getJSDocTypeAssertionType(node) { + var type = ts.getJSDocType(node); + ts.Debug.assertIsDefined(type); + return type; + } + ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 15 /* All */; } switch (node.kind) { - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: + if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + return false; + } return (kinds & 1 /* Parentheses */) !== 0; - case 209 /* TypeAssertionExpression */: - case 227 /* AsExpression */: + case 210 /* TypeAssertionExpression */: + case 228 /* AsExpression */: return (kinds & 2 /* TypeAssertions */) !== 0; - case 228 /* NonNullExpression */: + case 229 /* NonNullExpression */: return (kinds & 4 /* NonNullAssertions */) !== 0; - case 345 /* PartiallyEmittedExpression */: + case 348 /* PartiallyEmittedExpression */: return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -28973,7 +29179,7 @@ var ts; if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { var namedBindings = void 0; var moduleKind = ts.getEmitModuleKind(compilerOptions); - if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) { + if ((moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) || sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) { // use named imports var helpers = ts.getEmitHelpers(sourceFile); if (helpers) { @@ -28992,8 +29198,8 @@ var ts; // Alias the imports if the names are used somewhere in the file. // NOTE: We don't need to care about global import collisions as this is a module. namedBindings = nodeFactory.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name) - ? nodeFactory.createImportSpecifier(/*propertyName*/ undefined, nodeFactory.createIdentifier(name)) - : nodeFactory.createImportSpecifier(nodeFactory.createIdentifier(name), helperFactory.getUnscopedHelperName(name)); })); + ? nodeFactory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, nodeFactory.createIdentifier(name)) + : nodeFactory.createImportSpecifier(/*isTypeOnly*/ false, nodeFactory.createIdentifier(name), helperFactory.getUnscopedHelperName(name)); })); var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile); var emitNode = ts.getOrCreateEmitNode(parseNode); emitNode.externalHelpers = true; @@ -29010,7 +29216,8 @@ var ts; if (namedBindings) { var externalHelpersImportDeclaration = nodeFactory.createImportDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText)); + /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), + /*assertClause*/ undefined); ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); return externalHelpersImportDeclaration; } @@ -29024,9 +29231,9 @@ var ts; return externalHelpersModuleName; } var moduleKind = ts.getEmitModuleKind(compilerOptions); - var create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault)) + var create = (hasExportStarsToExportValues || (ts.getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault)) && moduleKind !== ts.ModuleKind.System - && moduleKind < ts.ModuleKind.ES2015; + && (moduleKind < ts.ModuleKind.ES2015 || node.impliedNodeFormat === ts.ModuleKind.CommonJS); if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { @@ -29056,10 +29263,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 264 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 265 /* ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 270 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 271 /* ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -29178,7 +29385,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -29190,11 +29397,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 293 /* SpreadAssignment */: + case 296 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -29226,12 +29433,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 162 /* Parameter */: - case 201 /* BindingElement */: + case 163 /* Parameter */: + case 202 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 223 /* SpreadElement */: - case 293 /* SpreadAssignment */: + case 224 /* SpreadElement */: + case 296 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -29249,7 +29456,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 201 /* BindingElement */: + case 202 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -29264,7 +29471,7 @@ var ts; : propertyName; } break; - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -29279,7 +29486,7 @@ var ts; : propertyName; } break; - case 293 /* SpreadAssignment */: + case 296 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -29302,13 +29509,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 199 /* ObjectBindingPattern */: - case 200 /* ArrayBindingPattern */: - case 202 /* ArrayLiteralExpression */: + case 200 /* ObjectBindingPattern */: + case 201 /* ArrayBindingPattern */: + case 203 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -29329,29 +29536,29 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - 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 */; + return kind === 163 /* Parameter */ + || kind === 165 /* PropertySignature */ + || kind === 166 /* PropertyDeclaration */ + || kind === 167 /* MethodSignature */ + || kind === 168 /* MethodDeclaration */ + || kind === 170 /* Constructor */ + || kind === 171 /* GetAccessor */ + || kind === 172 /* SetAccessor */ + || kind === 175 /* IndexSignature */ + || kind === 212 /* FunctionExpression */ + || kind === 213 /* ArrowFunction */ + || kind === 225 /* ClassExpression */ + || kind === 236 /* VariableStatement */ + || kind === 255 /* FunctionDeclaration */ + || kind === 256 /* ClassDeclaration */ + || kind === 257 /* InterfaceDeclaration */ + || kind === 258 /* TypeAliasDeclaration */ + || kind === 259 /* EnumDeclaration */ + || kind === 260 /* ModuleDeclaration */ + || kind === 264 /* ImportEqualsDeclaration */ + || kind === 265 /* ImportDeclaration */ + || kind === 270 /* ExportAssignment */ + || kind === 271 /* ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -29698,19 +29905,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 <= 158 /* LastToken */) { + if (!node || node.kind <= 159 /* LastToken */) { return; } switch (node.kind) { - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 161 /* TypeParameter */: + case 162 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -29718,9 +29925,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 293 /* SpreadAssignment */: + case 296 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 162 /* Parameter */: + case 163 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -29728,7 +29935,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -29736,51 +29943,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 164 /* PropertySignature */: + case 165 /* 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 291 /* PropertyAssignment */: + case 294 /* 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 252 /* VariableDeclaration */: + case 253 /* 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 201 /* BindingElement */: + case 202 /* 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 177 /* FunctionType */: - case 178 /* ConstructorType */: - case 172 /* CallSignature */: - case 173 /* ConstructSignature */: - case 174 /* IndexSignature */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 175 /* 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 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: - case 169 /* Constructor */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 211 /* FunctionExpression */: - case 254 /* FunctionDeclaration */: - case 212 /* ArrowFunction */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 212 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 213 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -29792,333 +29999,341 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 168 /* ClassStaticBlockDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 176 /* TypeReference */: + case 177 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 175 /* TypePredicate */: + case 176 /* TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 179 /* TypeQuery */: + case 180 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 180 /* TypeLiteral */: + case 181 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 181 /* ArrayType */: + case 182 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 182 /* TupleType */: + case 183 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 185 /* UnionType */: - case 186 /* IntersectionType */: + case 186 /* UnionType */: + case 187 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 187 /* ConditionalType */: + case 188 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 188 /* InferType */: + case 189 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 198 /* ImportType */: + case 199 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 189 /* ParenthesizedType */: - case 191 /* TypeOperator */: + case 190 /* ParenthesizedType */: + case 192 /* TypeOperator */: return visitNode(cbNode, node.type); - case 192 /* IndexedAccessType */: + case 193 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 193 /* MappedType */: + case 194 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.type); - case 194 /* LiteralType */: + visitNode(cbNode, node.type) || + visitNodes(cbNode, cbNodes, node.members); + case 195 /* LiteralType */: return visitNode(cbNode, node.literal); - case 195 /* NamedTupleMember */: + case 196 /* NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 199 /* ObjectBindingPattern */: - case 200 /* ArrayBindingPattern */: + case 200 /* ObjectBindingPattern */: + case 201 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 206 /* CallExpression */: - case 207 /* NewExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 209 /* TypeAssertionExpression */: + case 210 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 213 /* DeleteExpression */: + case 214 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 214 /* TypeOfExpression */: + case 215 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 215 /* VoidExpression */: + case 216 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 216 /* AwaitExpression */: + case 217 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 218 /* PostfixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 227 /* AsExpression */: + case 228 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 228 /* NonNullExpression */: + case 229 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 229 /* MetaProperty */: + case 230 /* MetaProperty */: return visitNode(cbNode, node.name); - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 223 /* SpreadElement */: + case 224 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 233 /* Block */: - case 260 /* ModuleBlock */: + case 234 /* Block */: + case 261 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 300 /* SourceFile */: + case 303 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 253 /* VariableDeclarationList */: + case 254 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 237 /* IfStatement */: + case 238 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 238 /* DoStatement */: + case 239 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 239 /* WhileStatement */: + case 240 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForOfStatement */: + case 243 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 243 /* ContinueStatement */: - case 244 /* BreakStatement */: + case 244 /* ContinueStatement */: + case 245 /* BreakStatement */: return visitNode(cbNode, node.label); - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 246 /* WithStatement */: + case 247 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 261 /* CaseBlock */: + case 262 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 287 /* CaseClause */: + case 288 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 288 /* DefaultClause */: + case 289 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 249 /* ThrowStatement */: + case 250 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 250 /* TryStatement */: + case 251 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 290 /* CatchClause */: + case 291 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 163 /* Decorator */: + case 164 /* Decorator */: return visitNode(cbNode, node.expression); - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* 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 256 /* InterfaceDeclaration */: + case 257 /* 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 257 /* TypeAliasDeclaration */: + case 258 /* 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 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 294 /* EnumMember */: + case 297 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || - visitNode(cbNode, node.moduleSpecifier); - case 265 /* ImportClause */: + visitNode(cbNode, node.moduleSpecifier) || + visitNode(cbNode, node.assertClause); + case 266 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 262 /* NamespaceExportDeclaration */: + case 292 /* AssertClause */: + return visitNodes(cbNode, cbNodes, node.elements); + case 293 /* AssertEntry */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.value); + case 263 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 266 /* NamespaceImport */: + case 267 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 272 /* NamespaceExport */: + case 273 /* NamespaceExport */: return visitNode(cbNode, node.name); - case 267 /* NamedImports */: - case 271 /* NamedExports */: + case 268 /* NamedImports */: + case 272 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || - visitNode(cbNode, node.moduleSpecifier); - case 268 /* ImportSpecifier */: - case 273 /* ExportSpecifier */: + visitNode(cbNode, node.moduleSpecifier) || + visitNode(cbNode, node.assertClause); + case 269 /* ImportSpecifier */: + case 274 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 221 /* TemplateExpression */: + case 222 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 231 /* TemplateSpan */: + case 232 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 196 /* TemplateLiteralType */: + case 197 /* TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 197 /* TemplateLiteralTypeSpan */: + case 198 /* TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 289 /* HeritageClause */: + case 290 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 275 /* ExternalModuleReference */: + case 276 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 274 /* MissingDeclaration */: + case 275 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 346 /* CommaListExpression */: + case 349 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 276 /* JsxElement */: + case 277 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 280 /* JsxFragment */: + case 281 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 277 /* JsxSelfClosingElement */: - case 278 /* JsxOpeningElement */: + case 278 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 284 /* JsxAttributes */: + case 285 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 283 /* JsxAttribute */: + case 284 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 285 /* JsxSpreadAttribute */: + case 286 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 286 /* JsxExpression */: + case 287 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 279 /* JsxClosingElement */: + case 280 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 183 /* OptionalType */: - case 184 /* RestType */: - case 304 /* JSDocTypeExpression */: - case 310 /* JSDocNonNullableType */: - case 309 /* JSDocNullableType */: - case 311 /* JSDocOptionalType */: - case 313 /* JSDocVariadicType */: + case 184 /* OptionalType */: + case 185 /* RestType */: + case 307 /* JSDocTypeExpression */: + case 313 /* JSDocNonNullableType */: + case 312 /* JSDocNullableType */: + case 314 /* JSDocOptionalType */: + case 316 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 312 /* JSDocFunctionType */: + case 315 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 315 /* JSDocComment */: + case 318 /* JSDocComment */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 341 /* JSDocSeeTag */: + case 344 /* JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 305 /* JSDocNameReference */: + case 308 /* JSDocNameReference */: return visitNode(cbNode, node.name); - case 306 /* JSDocMemberName */: + case 309 /* JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 335 /* JSDocParameterTag */: - case 342 /* JSDocPropertyTag */: + case 338 /* JSDocParameterTag */: + case 345 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -30127,64 +30342,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 325 /* JSDocAuthorTag */: + case 328 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 324 /* JSDocImplementsTag */: + case 327 /* JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocAugmentsTag */: + case 326 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 339 /* JSDocTemplateTag */: + case 342 /* 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 340 /* JSDocTypedefTag */: + case 343 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 304 /* JSDocTypeExpression */ + node.typeExpression.kind === 307 /* 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 333 /* JSDocCallbackTag */: + case 336 /* 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 336 /* JSDocReturnTag */: - case 338 /* JSDocTypeTag */: - case 337 /* JSDocThisTag */: - case 334 /* JSDocEnumTag */: + case 339 /* JSDocReturnTag */: + case 341 /* JSDocTypeTag */: + case 340 /* JSDocThisTag */: + case 337 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 318 /* JSDocSignature */: + case 321 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 319 /* JSDocLink */: - case 320 /* JSDocLinkCode */: - case 321 /* JSDocLinkPlain */: + case 322 /* JSDocLink */: + case 323 /* JSDocLinkCode */: + case 324 /* JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 317 /* JSDocTypeLiteral */: + case 320 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 322 /* JSDocTag */: - case 327 /* JSDocClassTag */: - case 328 /* JSDocPublicTag */: - case 329 /* JSDocPrivateTag */: - case 330 /* JSDocProtectedTag */: - case 331 /* JSDocReadonlyTag */: - case 326 /* JSDocDeprecatedTag */: + case 325 /* JSDocTag */: + case 330 /* JSDocClassTag */: + case 331 /* JSDocPublicTag */: + case 332 /* JSDocPrivateTag */: + case 333 /* JSDocProtectedTag */: + case 334 /* JSDocReadonlyTag */: + case 329 /* JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* PartiallyEmittedExpression */: + case 348 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -30233,7 +30448,7 @@ var ts; continue; return res; } - if (current.kind >= 159 /* FirstNode */) { + if (current.kind >= 160 /* 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]; @@ -31033,7 +31248,7 @@ var ts; } // 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() === 131 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { return false; } return token() > 116 /* LastReservedWord */; @@ -31127,7 +31342,7 @@ var ts; parseErrorAtCurrentToken(blankDiagnostic); } else { - parseErrorAtCurrentToken(nameDiagnostic, ts.tokenToString(token())); + parseErrorAtCurrentToken(nameDiagnostic, scanner.getTokenValue()); } } function getSpaceSuggestion(expressionText) { @@ -31276,7 +31491,7 @@ var ts; ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 274 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 275 /* MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -31332,6 +31547,10 @@ var ts; token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */; } + function isAssertionKey() { + return ts.tokenIsIdentifierOrKeyword(token()) || + token() === 10 /* StringLiteral */; + } function parsePropertyNameWorker(allowComputedPropertyNames) { if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { var node = parseLiteralNode(); @@ -31395,16 +31614,15 @@ var ts; if (token() === 88 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 150 /* TypeKeyword */) { + if (token() === 151 /* TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); case 88 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); case 124 /* StaticKeyword */: - return nextTokenIsOnSameLineAndCanFollowModifier(); - case 135 /* GetKeyword */: - case 147 /* SetKeyword */: + case 136 /* GetKeyword */: + case 148 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -31436,7 +31654,7 @@ var ts; return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || token() === 118 /* InterfaceKeyword */ || (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 130 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -31483,6 +31701,8 @@ var ts; return isLiteralPropertyName(); case 9 /* ObjectBindingElements */: return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* AssertEntries */: + return isAssertionKey(); case 7 /* HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. @@ -31588,6 +31808,7 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 23 /* ImportOrExportSpecifiers */: + case 24 /* AssertEntries */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; @@ -31646,7 +31867,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 24 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -31813,20 +32034,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 169 /* Constructor */: - case 174 /* IndexSignature */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 165 /* PropertyDeclaration */: - case 232 /* SemicolonClassElement */: + case 170 /* Constructor */: + case 175 /* IndexSignature */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 166 /* PropertyDeclaration */: + case 233 /* SemicolonClassElement */: return true; - case 167 /* MethodDeclaration */: + case 168 /* 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 === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 133 /* ConstructorKeyword */; + methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -31835,8 +32056,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 287 /* CaseClause */: - case 288 /* DefaultClause */: + case 288 /* CaseClause */: + case 289 /* DefaultClause */: return true; } } @@ -31845,58 +32066,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - 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 */: + case 255 /* FunctionDeclaration */: + case 236 /* VariableStatement */: + case 234 /* Block */: + case 238 /* IfStatement */: + case 237 /* ExpressionStatement */: + case 250 /* ThrowStatement */: + case 246 /* ReturnStatement */: + case 248 /* SwitchStatement */: + case 245 /* BreakStatement */: + case 244 /* ContinueStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 241 /* ForStatement */: + case 240 /* WhileStatement */: + case 247 /* WithStatement */: + case 235 /* EmptyStatement */: + case 251 /* TryStatement */: + case 249 /* LabeledStatement */: + case 239 /* DoStatement */: + case 252 /* DebuggerStatement */: + case 265 /* ImportDeclaration */: + case 264 /* ImportEqualsDeclaration */: + case 271 /* ExportDeclaration */: + case 270 /* ExportAssignment */: + case 260 /* ModuleDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 259 /* EnumDeclaration */: + case 258 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 294 /* EnumMember */; + return node.kind === 297 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 173 /* ConstructSignature */: - case 166 /* MethodSignature */: - case 174 /* IndexSignature */: - case 164 /* PropertySignature */: - case 172 /* CallSignature */: + case 174 /* ConstructSignature */: + case 167 /* MethodSignature */: + case 175 /* IndexSignature */: + case 165 /* PropertySignature */: + case 173 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 252 /* VariableDeclaration */) { + if (node.kind !== 253 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -31917,7 +32138,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 162 /* Parameter */) { + if (node.kind !== 163 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -31957,7 +32178,10 @@ var ts; case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* Parameters */: + return ts.isKeyword(token()) + ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) + : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); @@ -32201,14 +32425,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 176 /* TypeReference */: + case 177 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 177 /* FunctionType */: - case 178 /* ConstructorType */: { + case 178 /* FunctionType */: + case 179 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 189 /* ParenthesizedType */: + case 190 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -32288,7 +32512,7 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(140 /* ModuleKeyword */)) { + if (parseOptional(141 /* 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) { @@ -32490,14 +32714,14 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 173 /* ConstructSignature */) { + if (kind === 174 /* ConstructSignature */) { parseExpected(103 /* NewKeyword */); } var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 172 /* CallSignature */ + var node = kind === 173 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -32590,8 +32814,8 @@ var ts; // Return true if we have the start of a signature member if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || - token() === 135 /* GetKeyword */ || - token() === 147 /* SetKeyword */) { + token() === 136 /* GetKeyword */ || + token() === 148 /* SetKeyword */) { return true; } var idToken = false; @@ -32623,19 +32847,19 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(172 /* CallSignature */); + return parseSignatureMember(173 /* CallSignature */); } if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(173 /* ConstructSignature */); + return parseSignatureMember(174 /* ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(135 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 170 /* GetAccessor */); + if (parseContextualModifier(136 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 171 /* GetAccessor */); } - if (parseContextualModifier(147 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 171 /* SetAccessor */); + if (parseContextualModifier(148 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SetAccessor */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -32676,9 +32900,9 @@ var ts; function isStartOfMappedType() { nextToken(); if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 143 /* ReadonlyKeyword */; + return nextToken() === 144 /* ReadonlyKeyword */; } - if (token() === 143 /* ReadonlyKeyword */) { + if (token() === 144 /* ReadonlyKeyword */) { nextToken(); } return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; @@ -32694,10 +32918,10 @@ var ts; var pos = getNodePos(); parseExpected(18 /* OpenBraceToken */); var readonlyToken; - if (token() === 143 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 144 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 143 /* ReadonlyKeyword */) { - parseExpected(143 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 144 /* ReadonlyKeyword */) { + parseExpected(144 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); @@ -32713,8 +32937,9 @@ var ts; } var type = parseTypeAnnotation(); parseSemicolon(); + var members = parseList(4 /* TypeMembers */, parseTypeMember); parseExpected(19 /* CloseBraceToken */); - return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), pos); + return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); @@ -32828,16 +33053,16 @@ var ts; } function parseNonArrayType() { switch (token()) { - 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 */: + case 130 /* AnyKeyword */: + case 154 /* UnknownKeyword */: + case 149 /* StringKeyword */: + case 146 /* NumberKeyword */: + case 157 /* BigIntKeyword */: + case 150 /* SymbolKeyword */: + case 133 /* BooleanKeyword */: + case 152 /* UndefinedKeyword */: + case 143 /* NeverKeyword */: + case 147 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); case 66 /* AsteriskEqualsToken */: @@ -32870,7 +33095,7 @@ var ts; return parseTokenNode(); case 108 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { @@ -32897,21 +33122,21 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - 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 130 /* AnyKeyword */: + case 154 /* UnknownKeyword */: + case 149 /* StringKeyword */: + case 146 /* NumberKeyword */: + case 157 /* BigIntKeyword */: + case 133 /* BooleanKeyword */: + case 144 /* ReadonlyKeyword */: + case 150 /* SymbolKeyword */: + case 153 /* UniqueKeyword */: case 114 /* VoidKeyword */: - case 151 /* UndefinedKeyword */: + case 152 /* UndefinedKeyword */: case 104 /* NullKeyword */: case 108 /* ThisKeyword */: case 112 /* TypeOfKeyword */: - case 142 /* NeverKeyword */: + case 143 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: case 29 /* LessThanToken */: @@ -32923,12 +33148,12 @@ var ts; case 9 /* BigIntLiteral */: case 110 /* TrueKeyword */: case 95 /* FalseKeyword */: - case 146 /* ObjectKeyword */: + case 147 /* ObjectKeyword */: case 41 /* AsteriskToken */: case 57 /* QuestionToken */: case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 136 /* InferKeyword */: + case 137 /* InferKeyword */: case 100 /* ImportKeyword */: case 128 /* AssertsKeyword */: case 14 /* NoSubstitutionTemplateLiteral */: @@ -32998,17 +33223,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(136 /* InferKeyword */); + parseExpected(137 /* InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 139 /* KeyOfKeyword */: - case 152 /* UniqueKeyword */: - case 143 /* ReadonlyKeyword */: + case 140 /* KeyOfKeyword */: + case 153 /* UniqueKeyword */: + case 144 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 136 /* InferKeyword */: + case 137 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -33128,7 +33353,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 138 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -33137,7 +33362,7 @@ var ts; var pos = getNodePos(); var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(138 /* IsKeyword */) ? parseType() : undefined; + var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { @@ -33209,7 +33434,7 @@ var ts; case 45 /* PlusPlusToken */: case 46 /* MinusMinusToken */: case 29 /* LessThanToken */: - case 131 /* AwaitKeyword */: + case 132 /* AwaitKeyword */: case 125 /* YieldKeyword */: case 80 /* PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case @@ -33398,7 +33623,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() === 130 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } if (token() === 38 /* EqualsGreaterThanToken */) { @@ -33411,7 +33636,7 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 130 /* AsyncKeyword */) { + if (token() === 131 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; @@ -33455,7 +33680,7 @@ 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 !== 130 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -33534,7 +33759,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 130 /* AsyncKeyword */) { + if (token() === 131 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); @@ -33548,7 +33773,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() === 130 /* AsyncKeyword */) { + if (token() === 131 /* 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" @@ -33669,7 +33894,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 158 /* OfKeyword */; + return t === 101 /* InKeyword */ || t === 159 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -33756,7 +33981,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 131 /* AwaitKeyword */) { + if (token() === 132 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -33809,7 +34034,7 @@ var ts; if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 209 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 210 /* 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 { @@ -33850,7 +34075,7 @@ var ts; // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 131 /* AwaitKeyword */: + case 132 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -33880,7 +34105,7 @@ var ts; case 89 /* DeleteKeyword */: case 112 /* TypeOfKeyword */: case 114 /* VoidKeyword */: - case 131 /* AwaitKeyword */: + case 132 /* AwaitKeyword */: return false; case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression @@ -34060,18 +34285,18 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 278 /* JsxOpeningElement */) { + if (opening.kind === 279 /* JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 276 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 277 /* 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 (
(...
)) --> (
(...)
) + // 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); + var end = lastChild.children.end; + var newLast = finishNode(factory.createJsxElement(lastChild.openingElement, lastChild.children, 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; } @@ -34090,11 +34315,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 281 /* JsxOpeningFragment */) { + else if (opening.kind === 282 /* JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 277 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 278 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -34164,7 +34389,7 @@ var ts; break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 276 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 277 /* 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 @@ -34542,7 +34767,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 130 /* AsyncKeyword */: + case 131 /* 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. @@ -34564,6 +34789,8 @@ var ts; break; case 15 /* TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); + case 80 /* PrivateIdentifier */: + return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } @@ -34606,11 +34833,11 @@ var ts; } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(135 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* GetAccessor */); + if (parseContextualModifier(136 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 171 /* GetAccessor */); } - if (parseContextualModifier(147 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 171 /* SetAccessor */); + if (parseContextualModifier(148 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SetAccessor */); } var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -34816,7 +35043,7 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(131 /* AwaitKeyword */); + var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { @@ -34828,7 +35055,7 @@ var ts; } } var node; - if (awaitToken ? parseExpected(158 /* OfKeyword */) : parseOptional(158 /* OfKeyword */)) { + if (awaitToken ? parseExpected(159 /* OfKeyword */) : parseOptional(159 /* OfKeyword */)) { var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); @@ -34855,10 +35082,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 244 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 245 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 244 /* BreakStatement */ + var node = kind === 245 /* BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35047,25 +35274,25 @@ var ts; // // could be legal, it would add complexity for very little gain. case 118 /* InterfaceKeyword */: - case 150 /* TypeKeyword */: + case 151 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 140 /* ModuleKeyword */: - case 141 /* NamespaceKeyword */: + case 141 /* ModuleKeyword */: + case 142 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); case 126 /* AbstractKeyword */: - case 130 /* AsyncKeyword */: - case 134 /* DeclareKeyword */: + case 131 /* AsyncKeyword */: + case 135 /* DeclareKeyword */: case 121 /* PrivateKeyword */: case 122 /* ProtectedKeyword */: case 123 /* PublicKeyword */: - case 143 /* ReadonlyKeyword */: + case 144 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 155 /* GlobalKeyword */: + case 156 /* GlobalKeyword */: nextToken(); return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; case 100 /* ImportKeyword */: @@ -35074,7 +35301,7 @@ var ts; token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); case 93 /* ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 150 /* TypeKeyword */) { + if (currentToken_1 === 151 /* TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || @@ -35127,20 +35354,20 @@ var ts; case 85 /* ConstKeyword */: case 93 /* ExportKeyword */: return isStartOfDeclaration(); - case 130 /* AsyncKeyword */: - case 134 /* DeclareKeyword */: + case 131 /* AsyncKeyword */: + case 135 /* DeclareKeyword */: case 118 /* InterfaceKeyword */: - case 140 /* ModuleKeyword */: - case 141 /* NamespaceKeyword */: - case 150 /* TypeKeyword */: - case 155 /* GlobalKeyword */: + case 141 /* ModuleKeyword */: + case 142 /* NamespaceKeyword */: + case 151 /* TypeKeyword */: + case 156 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 123 /* PublicKeyword */: case 121 /* PrivateKeyword */: case 122 /* ProtectedKeyword */: case 124 /* StaticKeyword */: - case 143 /* ReadonlyKeyword */: + case 144 /* 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); @@ -35183,9 +35410,9 @@ var ts; case 97 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(243 /* ContinueStatement */); + return parseBreakOrContinueStatement(244 /* ContinueStatement */); case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(244 /* BreakStatement */); + return parseBreakOrContinueStatement(245 /* BreakStatement */); case 105 /* ReturnKeyword */: return parseReturnStatement(); case 116 /* WithKeyword */: @@ -35204,12 +35431,12 @@ var ts; return parseDebuggerStatement(); case 59 /* AtToken */: return parseDeclaration(); - case 130 /* AsyncKeyword */: + case 131 /* AsyncKeyword */: case 118 /* InterfaceKeyword */: - case 150 /* TypeKeyword */: - case 140 /* ModuleKeyword */: - case 141 /* NamespaceKeyword */: - case 134 /* DeclareKeyword */: + case 151 /* TypeKeyword */: + case 141 /* ModuleKeyword */: + case 142 /* NamespaceKeyword */: + case 135 /* DeclareKeyword */: case 85 /* ConstKeyword */: case 92 /* EnumKeyword */: case 93 /* ExportKeyword */: @@ -35219,8 +35446,8 @@ var ts; case 123 /* PublicKeyword */: case 126 /* AbstractKeyword */: case 124 /* StaticKeyword */: - case 143 /* ReadonlyKeyword */: - case 155 /* GlobalKeyword */: + case 144 /* ReadonlyKeyword */: + case 156 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -35229,7 +35456,7 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 134 /* DeclareKeyword */; + return modifier.kind === 135 /* DeclareKeyword */; } function parseDeclaration() { // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner @@ -35280,13 +35507,13 @@ var ts; return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); case 118 /* InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 150 /* TypeKeyword */: + case 151 /* TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); case 92 /* EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 155 /* GlobalKeyword */: - case 140 /* ModuleKeyword */: - case 141 /* NamespaceKeyword */: + case 156 /* GlobalKeyword */: + case 141 /* ModuleKeyword */: + case 142 /* NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); case 100 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -35305,7 +35532,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(274 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(275 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -35425,7 +35652,7 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 158 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 159 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { @@ -35467,8 +35694,8 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 133 /* ConstructorKeyword */) { - return parseExpected(133 /* ConstructorKeyword */); + if (token() === 134 /* ConstructorKeyword */) { + return parseExpected(134 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -35529,12 +35756,12 @@ var ts; var parameters = parseParameters(0 /* None */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 170 /* GetAccessor */ + var node = kind === 171 /* 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 === 171 /* SetAccessor */) + if (type && node.kind === 172 /* SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -35573,7 +35800,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 === 147 /* SetKeyword */ || idToken === 135 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 148 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -35613,7 +35840,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 131 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* 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(); @@ -35640,7 +35867,7 @@ var ts; } return list && createNodeArray(list, pos); } - function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) { + function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { @@ -35653,6 +35880,9 @@ var ts; else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } + else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + return undefined; + } else { if (!parseAnyContextualModifier()) { return undefined; @@ -35669,18 +35899,20 @@ var ts; */ function parseModifiers(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock) { var pos = getNodePos(); - var list, modifier; - while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock)) { + var list, modifier, hasSeenStatic = false; + while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { + if (modifier.kind === 124 /* StaticKeyword */) + hasSeenStatic = true; list = ts.append(list, modifier); } return list && createNodeArray(list, pos); } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 130 /* AsyncKeyword */) { + if (token() === 131 /* AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(130 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -35697,13 +35929,13 @@ var ts; if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(135 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 170 /* GetAccessor */); + if (parseContextualModifier(136 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 171 /* GetAccessor */); } - if (parseContextualModifier(147 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 171 /* SetAccessor */); + if (parseContextualModifier(148 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SetAccessor */); } - if (token() === 133 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -35740,10 +35972,10 @@ var ts; return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 224 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 225 /* ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 255 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 256 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); @@ -35765,7 +35997,7 @@ var ts; members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 255 /* ClassDeclaration */ + var node = kind === 256 /* ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35825,11 +36057,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(150 /* TypeKeyword */); + parseExpected(151 /* TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); parseExpected(63 /* EqualsToken */); - var type = token() === 137 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -35885,7 +36117,7 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 155 /* GlobalKeyword */) { + if (token() === 156 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); flags |= 1024 /* GlobalAugmentation */; @@ -35906,15 +36138,15 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 155 /* GlobalKeyword */) { + if (token() === 156 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(141 /* NamespaceKeyword */)) { + else if (parseOptional(142 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(140 /* ModuleKeyword */); + parseExpected(141 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } @@ -35922,7 +36154,7 @@ var ts; return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 144 /* RequireKeyword */ && + return token() === 145 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { @@ -35936,7 +36168,7 @@ var ts; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { parseExpected(127 /* AsKeyword */); - parseExpected(141 /* NamespaceKeyword */); + parseExpected(142 /* NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -35954,7 +36186,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 154 /* FromKeyword */ && + if (token() !== 155 /* FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -35972,20 +36204,51 @@ var ts; token() === 18 /* OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(154 /* FromKeyword */); + parseExpected(155 /* FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); + var assertClause; + if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + assertClause = parseAssertClause(); + } parseSemicolon(); - var node = factory.createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier); + var node = factory.createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause); return withJSDoc(finishNode(node, pos), hasJSDoc); } + function parseAssertEntry() { + var pos = getNodePos(); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); + parseExpected(58 /* ColonToken */); + var value = parseLiteralLikeNode(10 /* StringLiteral */); + return finishNode(factory.createAssertEntry(name, value), pos); + } + function parseAssertClause() { + var pos = getNodePos(); + parseExpected(129 /* AssertKeyword */); + var openBracePosition = scanner.getTokenPos(); + if (parseExpected(18 /* OpenBraceToken */)) { + var multiLine = scanner.hasPrecedingLineBreak(); + var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* CloseBraceToken */)) { + var lastError = ts.lastOrUndefined(parseDiagnostics); + if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { + ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); + } + } + return finishNode(factory.createAssertClause(elements, multiLine), pos); + } + else { + var elements = createNodeArray([], getNodePos(), /*end*/ undefined, /*hasTrailingComma*/ false); + return finishNode(factory.createAssertClause(elements, /*multiLine*/ false), pos); + } + } function tokenAfterImportDefinitelyProducesImportDeclaration() { return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 154 /* FromKeyword */; + return token() === 27 /* CommaToken */ || token() === 155 /* FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { parseExpected(63 /* EqualsToken */); @@ -36007,7 +36270,7 @@ var ts; var namedBindings; if (!identifier || parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(267 /* NamedImports */); + namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(268 /* NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -36018,7 +36281,7 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(144 /* RequireKeyword */); + parseExpected(145 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); var expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -36055,16 +36318,16 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 267 /* NamedImports */ + var node = kind === 268 /* 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(273 /* ExportSpecifier */); + return parseImportOrExportSpecifier(274 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(268 /* ImportSpecifier */); + return parseImportOrExportSpecifier(269 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -36077,27 +36340,74 @@ var ts; var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); - var identifierName = parseIdentifierName(); + var isTypeOnly = false; var propertyName; - var name; - if (token() === 127 /* AsKeyword */) { - propertyName = identifierName; - parseExpected(127 /* AsKeyword */); - checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); - checkIdentifierStart = scanner.getTokenPos(); - checkIdentifierEnd = scanner.getTextPos(); - name = parseIdentifierName(); + var canParseAsKeyword = true; + var name = parseIdentifierName(); + if (name.escapedText === "type") { + // If the first token of an import specifier is 'type', there are a lot of possibilities, + // especially if we see 'as' afterwards: + // + // import { type } from "mod"; - isTypeOnly: false, name: type + // import { type as } from "mod"; - isTypeOnly: true, name: as + // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type + // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as + if (token() === 127 /* AsKeyword */) { + // { type as ...? } + var firstAs = parseIdentifierName(); + if (token() === 127 /* AsKeyword */) { + // { type as as ...? } + var secondAs = parseIdentifierName(); + if (ts.tokenIsIdentifierOrKeyword(token())) { + // { type as as something } + isTypeOnly = true; + propertyName = firstAs; + name = parseNameWithKeywordCheck(); + canParseAsKeyword = false; + } + else { + // { type as as } + propertyName = name; + name = secondAs; + canParseAsKeyword = false; + } + } + else if (ts.tokenIsIdentifierOrKeyword(token())) { + // { type as something } + propertyName = name; + canParseAsKeyword = false; + name = parseNameWithKeywordCheck(); + } + else { + // { type as } + isTypeOnly = true; + name = firstAs; + } + } + else if (ts.tokenIsIdentifierOrKeyword(token())) { + // { type something ...? } + isTypeOnly = true; + name = parseNameWithKeywordCheck(); + } } - else { - name = identifierName; + if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + propertyName = name; + parseExpected(127 /* AsKeyword */); + name = parseNameWithKeywordCheck(); } - if (kind === 268 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 269 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 268 /* ImportSpecifier */ - ? factory.createImportSpecifier(propertyName, name) - : factory.createExportSpecifier(propertyName, name); + var node = kind === 269 /* ImportSpecifier */ + ? factory.createImportSpecifier(isTypeOnly, propertyName, name) + : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); + function parseNameWithKeywordCheck() { + checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); + checkIdentifierStart = scanner.getTokenPos(); + checkIdentifierEnd = scanner.getTextPos(); + return parseIdentifierName(); + } } function parseNamespaceExport(pos) { return finishNode(factory.createNamespaceExport(parseIdentifierName()), pos); @@ -36107,28 +36417,32 @@ var ts; setAwaitContext(/*value*/ true); var exportClause; var moduleSpecifier; - var isTypeOnly = parseOptional(150 /* TypeKeyword */); + var assertClause; + var isTypeOnly = parseOptional(151 /* TypeKeyword */); var namespaceExportPos = getNodePos(); if (parseOptional(41 /* AsteriskToken */)) { if (parseOptional(127 /* AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(154 /* FromKeyword */); + parseExpected(155 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(271 /* NamedExports */); + exportClause = parseNamedImportsOrExports(272 /* 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() === 154 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(154 /* FromKeyword */); + if (token() === 155 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(155 /* FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } + if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + assertClause = parseAssertClause(); + } parseSemicolon(); setAwaitContext(savedAwaitContext); - var node = factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier); + var node = factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseExportAssignment(pos, hasJSDoc, decorators, modifiers) { @@ -36202,7 +36516,8 @@ var ts; ParsingContext[ParsingContext["TupleElementTypes"] = 21] = "TupleElementTypes"; ParsingContext[ParsingContext["HeritageClauses"] = 22] = "HeritageClauses"; ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 23] = "ImportOrExportSpecifiers"; - ParsingContext[ParsingContext["Count"] = 24] = "Count"; // Number of parsing contexts + ParsingContext[ParsingContext["AssertEntries"] = 24] = "AssertEntries"; + ParsingContext[ParsingContext["Count"] = 25] = "Count"; // Number of parsing contexts })(ParsingContext || (ParsingContext = {})); var Tristate; (function (Tristate) { @@ -36760,9 +37075,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 146 /* ObjectKeyword */: + case 147 /* ObjectKeyword */: return true; - case 181 /* ArrayType */: + case 182 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -36794,12 +37109,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 335 /* JSDocParameterTag */ || child.kind === 342 /* JSDocPropertyTag */) { + if (child.kind === 338 /* JSDocParameterTag */ || child.kind === 345 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 181 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 182 /* ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -36820,8 +37135,9 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; }); - var nameExpression = isLink ? undefined : parseJSDocNameReference(); + var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; }); + var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); } @@ -36916,7 +37232,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 338 /* JSDocTypeTag */) { + if (child.kind === 341 /* JSDocTypeTag */) { if (childTypeTag) { parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); var lastError = ts.lastOrUndefined(parseDiagnostics); @@ -36934,7 +37250,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 181 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 182 /* ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -36987,7 +37303,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 336 /* JSDocReturnTag */) { + if (tag && tag.kind === 339 /* JSDocReturnTag */) { return tag; } } @@ -37021,7 +37337,7 @@ var ts; case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 335 /* JSDocParameterTag */ || child.kind === 342 /* JSDocPropertyTag */) && + if (child && (child.kind === 338 /* JSDocParameterTag */ || child.kind === 345 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -37077,11 +37393,22 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); + var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + if (isBracketed) { + skipWhitespace(); + } var name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); + var defaultType; + if (isBracketed) { + skipWhitespace(); + parseExpected(63 /* EqualsToken */); + defaultType = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); + parseExpected(23 /* CloseBracketToken */); + } if (ts.nodeIsMissing(name)) { return undefined; } - return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, /*defaultType*/ undefined), typeParameterPos); + return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, defaultType), typeParameterPos); } function parseTemplateTagTypeParameters() { var pos = getNodePos(); @@ -37223,6 +37550,7 @@ var ts; // are already correct. var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind); result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks); + result.impliedNodeFormat = sourceFile.impliedNodeFormat; return result; } IncrementalParser.updateSourceFile = updateSourceFile; @@ -37672,7 +38000,7 @@ var ts; })(IncrementalParser || (IncrementalParser = {})); /** @internal */ function isDeclarationFileName(fileName) { - return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); + return ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]); } ts.isDeclarationFileName = isDeclarationFileName; /*@internal*/ @@ -37898,7 +38226,7 @@ var ts; var ts; (function (ts) { /* @internal */ - ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; + ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean", defaultValueDescription: "false" }; var jsxOptionMap = new ts.Map(ts.getEntries({ "preserve": 1 /* Preserve */, "react-native": 3 /* ReactNative */, @@ -37969,6 +38297,7 @@ var ts; ["es2021.promise", "lib.es2021.promise.d.ts"], ["es2021.string", "lib.es2021.string.d.ts"], ["es2021.weakref", "lib.es2021.weakref.d.ts"], + ["es2021.intl", "lib.es2021.intl.d.ts"], ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], @@ -38034,6 +38363,7 @@ var ts; type: "boolean", 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, + defaultValueDescription: "false", }, { name: "excludeDirectories", @@ -38069,11 +38399,13 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Print_this_message, + defaultValueDescription: "false", }, { name: "help", shortName: "?", - type: "boolean" + type: "boolean", + defaultValueDescription: "false", }, { name: "watch", @@ -38083,6 +38415,7 @@ var ts; isCommandLineOnly: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Watch_input_files, + defaultValueDescription: "false", }, { name: "preserveWatchOutput", @@ -38090,7 +38423,7 @@ var ts; showInSimplifiedHelpView: false, category: ts.Diagnostics.Output_Formatting, description: ts.Diagnostics.Disable_wiping_the_console_in_watch_mode, - defaultValueDescription: "n/a" + defaultValueDescription: "false", }, { name: "listFiles", @@ -38103,7 +38436,8 @@ var ts; name: "explainFiles", type: "boolean", category: ts.Diagnostics.Compiler_Diagnostics, - description: ts.Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included + description: ts.Diagnostics.Print_files_read_during_the_compilation_including_why_it_was_included, + defaultValueDescription: "false", }, { name: "listEmittedFiles", @@ -38174,7 +38508,8 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, 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 + 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, + defaultValueDescription: "false", }, { name: "locale", @@ -38219,6 +38554,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Show_all_compiler_options, + defaultValueDescription: "false", }, { name: "version", @@ -38227,6 +38563,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Print_the_compiler_s_version, + defaultValueDescription: "false", }, { name: "init", @@ -38234,6 +38571,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, + defaultValueDescription: "false", }, { name: "project", @@ -38251,7 +38589,8 @@ var ts; shortName: "b", showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, - description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date + description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date, + defaultValueDescription: "false", }, { name: "showConfig", @@ -38259,7 +38598,8 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Command_line_Options, isCommandLineOnly: true, - description: ts.Diagnostics.Print_the_final_configuration_instead_of_building + description: ts.Diagnostics.Print_the_final_configuration_instead_of_building, + defaultValueDescription: "false", }, { name: "listFilesOnly", @@ -38268,7 +38608,8 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, isCommandLineOnly: true, - description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing + description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing, + defaultValueDescription: "false", }, // Basic ts.targetOptionDeclaration, @@ -38284,7 +38625,10 @@ var ts; es6: ts.ModuleKind.ES2015, es2015: ts.ModuleKind.ES2015, es2020: ts.ModuleKind.ES2020, - esnext: ts.ModuleKind.ESNext + es2022: ts.ModuleKind.ES2022, + esnext: ts.ModuleKind.ESNext, + node12: ts.ModuleKind.Node12, + nodenext: ts.ModuleKind.NodeNext, })), affectsModuleResolution: true, affectsEmit: true, @@ -38385,7 +38729,6 @@ var ts; 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", @@ -38396,7 +38739,6 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_an_output_folder_for_all_emitted_files, - defaultValueDescription: "n/a" }, { name: "rootDir", @@ -38460,7 +38802,7 @@ var ts; type: new ts.Map(ts.getEntries({ remove: 0 /* Remove */, preserve: 1 /* Preserve */, - error: 2 /* Error */ + error: 2 /* Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, @@ -38553,6 +38895,7 @@ var ts; strictFlag: true, category: ts.Diagnostics.Type_Checking, description: ts.Diagnostics.Type_catch_clause_variables_as_unknown_instead_of_any, + defaultValueDescription: "false", }, { name: "alwaysStrict", @@ -38585,7 +38928,8 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, category: ts.Diagnostics.Type_Checking, - description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined + description: ts.Diagnostics.Interpret_optional_property_types_as_written_rather_than_adding_undefined, + defaultValueDescription: "false", }, { name: "noImplicitReturns", @@ -38601,21 +38945,24 @@ var ts; affectsBindDiagnostics: true, affectsSemanticDiagnostics: true, category: ts.Diagnostics.Type_Checking, - description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements + description: ts.Diagnostics.Enable_error_reporting_for_fallthrough_cases_in_switch_statements, + defaultValueDescription: "false", }, { name: "noUncheckedIndexedAccess", type: "boolean", affectsSemanticDiagnostics: true, category: ts.Diagnostics.Type_Checking, - description: ts.Diagnostics.Include_undefined_in_index_signature_results + description: ts.Diagnostics.Include_undefined_in_index_signature_results, + defaultValueDescription: "false", }, { name: "noImplicitOverride", type: "boolean", affectsSemanticDiagnostics: true, category: ts.Diagnostics.Type_Checking, - description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier + description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier, + defaultValueDescription: "false", }, { name: "noPropertyAccessFromIndexSignature", @@ -38631,6 +38978,8 @@ var ts; type: new ts.Map(ts.getEntries({ node: ts.ModuleResolutionKind.NodeJs, classic: ts.ModuleResolutionKind.Classic, + node12: ts.ModuleResolutionKind.Node12, + nodenext: ts.ModuleResolutionKind.NodeNext, })), affectsModuleResolution: true, paramType: ts.Diagnostics.STRATEGY, @@ -38722,7 +39071,7 @@ var ts; type: "boolean", 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" + defaultValueDescription: "false", }, { name: "allowUmdGlobalAccess", @@ -38771,7 +39120,8 @@ var ts; type: "boolean", affectsSemanticDiagnostics: true, category: ts.Diagnostics.Language_and_Environment, - description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators + description: ts.Diagnostics.Enable_experimental_support_for_TC39_stage_2_draft_decorators, + defaultValueDescription: "false", }, { name: "emitDecoratorMetadata", @@ -38779,7 +39129,8 @@ var ts; affectsSemanticDiagnostics: true, affectsEmit: true, category: ts.Diagnostics.Language_and_Environment, - description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files + description: ts.Diagnostics.Emit_design_type_metadata_for_decorated_declarations_in_source_files, + defaultValueDescription: "false", }, // Advanced { @@ -38822,7 +39173,6 @@ var ts; category: ts.Diagnostics.Backwards_Compatibility, paramType: ts.Diagnostics.FILE, transpileOptionValue: undefined, - defaultValueDescription: "n/a", description: ts.Diagnostics.Deprecated_setting_Use_outFile_instead, }, { @@ -38903,6 +39253,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Disable_emitting_declarations_that_have_internal_in_their_JSDoc_comments, + defaultValueDescription: "false", }, { name: "disableSizeLimit", @@ -38917,21 +39268,24 @@ var ts; type: "boolean", isTSConfigOnly: true, category: ts.Diagnostics.Projects, - description: ts.Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects + description: ts.Diagnostics.Disable_preferring_source_files_instead_of_declaration_files_when_referencing_composite_projects, + defaultValueDescription: "false", }, { name: "disableSolutionSearching", type: "boolean", isTSConfigOnly: true, category: ts.Diagnostics.Projects, - description: ts.Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing + description: ts.Diagnostics.Opt_a_project_out_of_multi_project_reference_checking_when_editing, + defaultValueDescription: "false", }, { name: "disableReferencedProjectLoad", type: "boolean", isTSConfigOnly: true, category: ts.Diagnostics.Projects, - description: ts.Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript + description: ts.Diagnostics.Reduce_the_number_of_projects_loaded_automatically_by_TypeScript, + defaultValueDescription: "false", }, { name: "noImplicitUseStrict", @@ -38964,7 +39318,7 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Disable_erasing_const_enum_declarations_in_generated_code, - defaultValueDescription: "n/a" + defaultValueDescription: "false", }, { name: "declarationDir", @@ -38975,7 +39329,6 @@ var ts; category: ts.Diagnostics.Emit, transpileOptionValue: undefined, description: ts.Diagnostics.Specify_the_output_directory_for_generated_declaration_files, - defaultValueDescription: "n/a" }, { name: "skipLibCheck", @@ -39049,7 +39402,15 @@ var ts; affectsEmit: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Emit_ECMAScript_standard_compliant_class_fields, - defaultValueDescription: "false" + defaultValueDescription: ts.Diagnostics.true_for_ES2022_and_above_including_ESNext + }, + { + name: "preserveValueImports", + type: "boolean", + affectsEmit: true, + category: ts.Diagnostics.Emit, + description: ts.Diagnostics.Preserve_unused_imported_values_in_the_JavaScript_output_that_would_otherwise_be_removed, + defaultValueDescription: "false", }, { name: "keyofStringsOnly", @@ -39097,27 +39458,31 @@ var ts; shortName: "v", category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Enable_verbose_logging, - type: "boolean" + type: "boolean", + defaultValueDescription: "false", }, { name: "dry", shortName: "d", category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean, - type: "boolean" + type: "boolean", + defaultValueDescription: "false", }, { name: "force", shortName: "f", category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date, - type: "boolean" + type: "boolean", + defaultValueDescription: "false", }, { name: "clean", category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Delete_the_outputs_of_all_projects, - type: "boolean" + type: "boolean", + defaultValueDescription: "false", } ]; /* @internal */ @@ -39130,10 +39495,12 @@ var ts; */ name: "enableAutoDiscovery", type: "boolean", + defaultValueDescription: "false", }, { name: "enable", type: "boolean", + defaultValueDescription: "false", }, { name: "include", @@ -39154,6 +39521,7 @@ var ts; { name: "disableFilenameBasedTypeAcquisition", type: "boolean", + defaultValueDescription: "false", }, ]; /*@internal*/ @@ -39182,7 +39550,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 1 /* ES5 */, + target: 3 /* ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -39653,7 +40021,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 !== 203 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 204 /* 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 @@ -39693,7 +40061,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 291 /* PropertyAssignment */) { + if (element.kind !== 294 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -39787,13 +40155,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 217 /* PrefixUnaryExpression */: + case 218 /* 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 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -39810,7 +40178,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -39982,6 +40350,44 @@ var ts; } return result; } + /** + * Generate a list of the compiler options whose value is not the default. + * @param options compilerOptions to be evaluated. + /** @internal */ + function getCompilerOptionsDiffValue(options, newLine) { + var compilerOptionsMap = getSerializedCompilerOption(options); + return getOverwrittenDefaultOptions(); + function makePadding(paddingLength) { + return Array(paddingLength + 1).join(" "); + } + function getOverwrittenDefaultOptions() { + var result = []; + var tab = makePadding(2); + commandOptionsWithoutBuild.forEach(function (cmd) { + if (!compilerOptionsMap.has(cmd.name)) { + return; + } + var newValue = compilerOptionsMap.get(cmd.name); + var defaultValue = getDefaultValueForOption(cmd); + if (newValue !== defaultValue) { + result.push("" + tab + cmd.name + ": " + newValue); + } + else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { + result.push("" + tab + cmd.name + ": " + defaultValue); + } + }); + return result.join(newLine) + newLine; + } + } + ts.getCompilerOptionsDiffValue = getCompilerOptionsDiffValue; + /** + * Get the compiler options to be written into the tsconfig.json. + * @param options commandlineOptions to be included in the compileOptions. + */ + function getSerializedCompilerOption(options) { + var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); + return serializeCompilerOptions(compilerOptions); + } /** * Generate tsconfig configuration when running command line "--init" * @param options commandlineOptions to be generated into tsconfig.json @@ -39989,28 +40395,8 @@ var ts; */ /* @internal */ function generateTSConfig(options, fileNames, newLine) { - var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); - var compilerOptionsMap = serializeCompilerOptions(compilerOptions); + var compilerOptionsMap = getSerializedCompilerOption(options); return writeConfigurations(); - function getDefaultValueForOption(option) { - switch (option.type) { - case "number": - return 1; - case "boolean": - return true; - case "string": - return option.isFilePath ? "./" : ""; - case "list": - return []; - case "object": - return {}; - default: - var iterResult = option.type.keys().next(); - if (!iterResult.done) - return iterResult.value; - return ts.Debug.fail("Expected 'option.type' to have entries."); - } - } function makePadding(paddingLength) { return Array(paddingLength + 1).join(" "); } @@ -40409,6 +40795,7 @@ var ts; var typeAcquisition, typingOptionstypeAcquisition; var watchOptions; var extendedConfigPath; + var rootCompilerOptions; var optionsIterator = { onSetValidOptionKeyValueInParent: function (parentOption, option, value) { var currentOption; @@ -40444,6 +40831,9 @@ var ts; if (key === "excludes") { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, keyNode, ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); } + if (ts.find(commandOptionsWithoutBuild, function (opt) { return opt.name === key; })) { + rootCompilerOptions = ts.append(rootCompilerOptions, keyNode); + } } }; var json = convertConfigFileToObject(sourceFile, errors, /*reportOptionsErrors*/ true, optionsIterator); @@ -40461,6 +40851,9 @@ var ts; typeAcquisition = getDefaultTypeAcquisition(configFileName); } } + if (rootCompilerOptions && json && json.compilerOptions === undefined) { + errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootCompilerOptions[0], ts.Diagnostics._0_should_be_set_inside_the_compilerOptions_object_of_the_config_json_file, ts.getTextOfPropertyName(rootCompilerOptions[0]))); + } return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath }; } function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) { @@ -40696,7 +41089,7 @@ var ts; // 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); + var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); // Literal files are always included verbatim. An "include" or "exclude" specification cannot // remove a literal file. if (validatedFilesSpec) { @@ -40744,7 +41137,7 @@ var ts; wildcardFileMap.set(key, file); } }; - for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) { + for (var _a = 0, _b = host.readDirectory(basePath, ts.flatten(supportedExtensionsWithJsonIfResolveJsonModule), validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined); _a < _b.length; _a++) { var file = _b[_a]; _loop_6(file); } @@ -40907,16 +41300,25 @@ var ts; * extension priority. * * @param file The path to the file. - * @param extensionPriority The priority of the extension. - * @param context The expansion context. */ function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions); - for (var i = 0 /* Highest */; i < adjustedExtensionPriority; i++) { - var higherPriorityExtension = extensions[i]; - var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension)); + var extensionGroup = ts.forEach(extensions, function (group) { return ts.fileExtensionIsOneOf(file, group) ? group : undefined; }); + if (!extensionGroup) { + return false; + } + for (var _i = 0, extensionGroup_1 = extensionGroup; _i < extensionGroup_1.length; _i++) { + var ext = extensionGroup_1[_i]; + if (ts.fileExtensionIs(file, ext)) { + return false; + } + var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { + if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration + // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to + // prevent breakage. + continue; + } return true; } } @@ -40927,15 +41329,18 @@ var ts; * already been included. * * @param file The path to the file. - * @param extensionPriority The priority of the extension. - * @param context The expansion context. */ function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) { - var extensionPriority = ts.getExtensionPriority(file, extensions); - var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions); - for (var i = nextExtensionPriority; i < extensions.length; i++) { - var lowerPriorityExtension = extensions[i]; - var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension)); + var extensionGroup = ts.forEach(extensions, function (group) { return ts.fileExtensionIsOneOf(file, group) ? group : undefined; }); + if (!extensionGroup) { + return; + } + for (var i = extensionGroup.length - 1; i >= 0; i--) { + var ext = extensionGroup[i]; + if (ts.fileExtensionIs(file, ext)) { + return; + } + var lowerPriorityPath = keyMapper(ts.changeExtension(file, ext)); wildcardFiles.delete(lowerPriorityPath); } } @@ -40978,6 +41383,25 @@ var ts; }); // TODO: GH#18217 } } + function getDefaultValueForOption(option) { + switch (option.type) { + case "number": + return 1; + case "boolean": + return true; + case "string": + return option.isFilePath ? "./" : ""; + case "list": + return []; + case "object": + return {}; + default: + var iterResult = option.type.keys().next(); + if (!iterResult.done) + return iterResult.value; + return ts.Debug.fail("Expected 'option.type' to have entries."); + } + } })(ts || (ts = {})); var ts; (function (ts) { @@ -41179,6 +41603,10 @@ var ts; return typeRoots; } var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); + function arePathsEqual(path1, path2, host) { + var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups @@ -41191,7 +41619,7 @@ var ts; } var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined; var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined; - var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName); + var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName, /*mode*/ undefined); if (result) { if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile); @@ -41225,7 +41653,7 @@ var ts; } } var failedLookupLocations = []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; + var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.AllFeatures, conditions: ["node", "require", "types"] }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -41239,13 +41667,13 @@ var ts; resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, - originalPath: fileName === resolvedFileName ? undefined : fileName, + originalPath: arePathsEqual(fileName, resolvedFileName, host) ? undefined : fileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName), }; } result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; - perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result); + perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ undefined, result); if (traceEnabled) traceResult(result); return result; @@ -41458,9 +41886,56 @@ var ts; } function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); - return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return new ts.Map(); }); + return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return createModeAwareCache(); }); + } + } + /* @internal */ + function createModeAwareCache() { + var underlying = new ts.Map(); + var memoizedReverseKeys = new ts.Map(); + var cache = { + get: function (specifier, mode) { + return underlying.get(getUnderlyingCacheKey(specifier, mode)); + }, + set: function (specifier, mode, value) { + underlying.set(getUnderlyingCacheKey(specifier, mode), value); + return cache; + }, + delete: function (specifier, mode) { + underlying.delete(getUnderlyingCacheKey(specifier, mode)); + return cache; + }, + has: function (specifier, mode) { + return underlying.has(getUnderlyingCacheKey(specifier, mode)); + }, + forEach: function (cb) { + return underlying.forEach(function (elem, key) { + var _a = memoizedReverseKeys.get(key), specifier = _a[0], mode = _a[1]; + return cb(elem, specifier, mode); + }); + }, + size: function () { + return underlying.size; + } + }; + return cache; + function getUnderlyingCacheKey(specifier, mode) { + var result = mode === undefined ? specifier : mode + "|" + specifier; + memoizedReverseKeys.set(result, [specifier, mode]); + return result; } } + ts.createModeAwareCache = createModeAwareCache; + /* @internal */ + function zipToModeAwareCache(file, keys, values) { + ts.Debug.assert(keys.length === values.length); + var map = createModeAwareCache(); + for (var i = 0; i < keys.length; ++i) { + map.set(keys[i], ts.getModeForResolutionAtIndex(file, i), values[i]); + } + return map; + } + ts.zipToModeAwareCache = zipToModeAwareCache; function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options)); @@ -41474,9 +41949,9 @@ var ts; function update(options) { updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); } - function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { + function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -41555,13 +42030,15 @@ var ts; } } ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; - function resolveModuleNameFromCache(moduleName, containingFile, cache) { + function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) { var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); - return perFolderCache && perFolderCache.get(moduleName); + if (!perFolderCache) + return undefined; + return perFolderCache.get(moduleName, mode); } ts.resolveModuleNameFromCache = resolveModuleNameFromCache; - function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { + function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (redirectedReference) { compilerOptions = redirectedReference.commandLine.options; @@ -41574,7 +42051,7 @@ var ts; } var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference); - var result = perFolderCache && perFolderCache.get(moduleName); + var result = perFolderCache && perFolderCache.get(moduleName, resolutionMode); if (result) { if (traceEnabled) { trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory); @@ -41583,7 +42060,20 @@ var ts; else { var moduleResolution = compilerOptions.moduleResolution; if (moduleResolution === undefined) { - moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + switch (ts.getEmitModuleKind(compilerOptions)) { + case ts.ModuleKind.CommonJS: + moduleResolution = ts.ModuleResolutionKind.NodeJs; + break; + case ts.ModuleKind.Node12: + moduleResolution = ts.ModuleResolutionKind.Node12; + break; + case ts.ModuleKind.NodeNext: + moduleResolution = ts.ModuleResolutionKind.NodeNext; + break; + default: + moduleResolution = ts.ModuleResolutionKind.Classic; + break; + } if (traceEnabled) { trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]); } @@ -41595,6 +42085,12 @@ var ts; } ts.perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { + case ts.ModuleResolutionKind.Node12: + result = node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + break; + case ts.ModuleResolutionKind.NodeNext: + result = nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + break; case ts.ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; @@ -41608,10 +42104,10 @@ var ts; ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { - perFolderCache.set(moduleName, result); + perFolderCache.set(moduleName, resolutionMode, result); if (!ts.isExternalModuleNameRelative(moduleName)) { // put result in per-module name cache - cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result); + cache.getOrCreateCacheForModuleName(moduleName, resolutionMode, redirectedReference).set(containingDirectory, result); } } } @@ -41815,26 +42311,63 @@ var ts; ts.resolveJSModule = resolveJSModule; /* @internal */ function tryResolveJSModule(moduleName, initialDir, host) { - var resolvedModule = tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule; - return resolvedModule && resolvedModule.resolvedFileName; + return tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule; } ts.tryResolveJSModule = tryResolveJSModule; + /* @internal */ + var NodeResolutionFeatures; + (function (NodeResolutionFeatures) { + NodeResolutionFeatures[NodeResolutionFeatures["None"] = 0] = "None"; + // resolving `#local` names in your own package.json + NodeResolutionFeatures[NodeResolutionFeatures["Imports"] = 2] = "Imports"; + // resolving `your-own-name` from your own package.json + NodeResolutionFeatures[NodeResolutionFeatures["SelfName"] = 4] = "SelfName"; + // respecting the `.exports` member of packages' package.json files and its (conditional) mappings of export names + NodeResolutionFeatures[NodeResolutionFeatures["Exports"] = 8] = "Exports"; + // allowing `*` in the LHS of an export to be followed by more content, eg `"./whatever/*.js"` + // not currently backported to node 12 - https://github.com/nodejs/Release/issues/690 + NodeResolutionFeatures[NodeResolutionFeatures["ExportsPatternTrailers"] = 16] = "ExportsPatternTrailers"; + NodeResolutionFeatures[NodeResolutionFeatures["AllFeatures"] = 30] = "AllFeatures"; + NodeResolutionFeatures[NodeResolutionFeatures["EsmMode"] = 32] = "EsmMode"; + })(NodeResolutionFeatures || (NodeResolutionFeatures = {})); + function node12ModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { + return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.Imports | NodeResolutionFeatures.SelfName | NodeResolutionFeatures.Exports, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + } + function nodeNextModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { + return nodeNextModuleNameResolverWorker(NodeResolutionFeatures.AllFeatures, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode); + } + function nodeNextModuleNameResolverWorker(features, moduleName, containingFile, compilerOptions, host, cache, redirectedReference, resolutionMode) { + var containingDirectory = ts.getDirectoryPath(containingFile); + // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features + var esmMode = resolutionMode === ts.ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0; + return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions, redirectedReference); + } var jsOnlyExtensions = [Extensions.JavaScript]; var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript]; 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); + return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) { - return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); + return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); } ts.nodeModuleNameResolver = nodeModuleNameResolver; - function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { + function nodeModuleNameResolverWorker(features, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; + // conditions are only used by the node12/nodenext resolver - there's no priority order in the list, + //it's essentially a set (priority is determined by object insertion order in the object we look at). + var state = { + compilerOptions: compilerOptions, + host: host, + traceEnabled: traceEnabled, + failedLookupLocations: failedLookupLocations, + packageJsonInfoCache: cache, + features: features, + conditions: features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] + }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); function tryResolve(extensions) { @@ -41844,16 +42377,25 @@ var ts; return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) }); } if (!ts.isExternalModuleNameRelative(moduleName)) { - if (traceEnabled) { - trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); + var resolved_1; + if (features & NodeResolutionFeatures.Imports && ts.startsWith(moduleName, "#")) { + resolved_1 = loadModuleFromImports(extensions, moduleName, containingDirectory, state, cache, redirectedReference); + } + if (!resolved_1 && features & NodeResolutionFeatures.SelfName) { + resolved_1 = loadModuleFromSelfNameReference(extensions, moduleName, containingDirectory, state, cache, redirectedReference); + } + if (!resolved_1) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]); + } + resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference); } - var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference); if (!resolved_1) return undefined; var resolvedValue = resolved_1.value; if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) { var path = realPath(resolvedValue.path, host, traceEnabled); - var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path; + var originalPath = arePathsEqual(path, resolvedValue.path, host) ? undefined : resolvedValue.path; resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath }); } // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files. @@ -41956,26 +42498,40 @@ var ts; function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); - return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state); + var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; + return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } - // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" - var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state); - if (resolvedByAddingExtension) { - return resolvedByAddingExtension; + // esm mode resolutions don't include automatic extension lookup (without additional flags, at least) + if (!(state.features & NodeResolutionFeatures.EsmMode)) { + // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" + var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } } + return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); + } + function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); + var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { - var extension = candidate.substring(extensionless.length); trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state); + } + } + function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) { + if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) { + var result = tryFile(candidate, onlyRecordFailures, state); + return result !== undefined ? { path: candidate, ext: ts.forEach([".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */], function (e) { return ts.fileExtensionIs(candidate, e) ? e : undefined; }) } : undefined; } + return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); } /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ - function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) { + function tryAddingExtensions(candidate, extensions, originalExtension, onlyRecordFailures, state) { if (!onlyRecordFailures) { // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing var directory = ts.getDirectoryPath(candidate); @@ -41985,11 +42541,51 @@ var ts; } switch (extensions) { case Extensions.DtsOnly: - return tryExtension(".d.ts" /* Dts */); + switch (originalExtension) { + case ".mjs" /* Mjs */: + case ".mts" /* Mts */: + case ".d.mts" /* Dmts */: + return tryExtension(".d.mts" /* Dmts */); + case ".cjs" /* Cjs */: + case ".cts" /* Cts */: + case ".d.cts" /* Dcts */: + return tryExtension(".d.cts" /* Dcts */); + case ".json" /* Json */: + candidate += ".json" /* Json */; + return tryExtension(".d.ts" /* Dts */); + default: return tryExtension(".d.ts" /* Dts */); + } case Extensions.TypeScript: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); + switch (originalExtension) { + case ".mjs" /* Mjs */: + case ".mts" /* Mts */: + case ".d.mts" /* Dmts */: + return tryExtension(".mts" /* Mts */) || tryExtension(".d.mts" /* Dmts */); + case ".cjs" /* Cjs */: + case ".cts" /* Cts */: + case ".d.cts" /* Dcts */: + return tryExtension(".cts" /* Cts */) || tryExtension(".d.cts" /* Dcts */); + case ".json" /* Json */: + candidate += ".json" /* Json */; + return tryExtension(".d.ts" /* Dts */); + default: + return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); + } case Extensions.JavaScript: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + switch (originalExtension) { + case ".mjs" /* Mjs */: + case ".mts" /* Mts */: + case ".d.mts" /* Dmts */: + return tryExtension(".mjs" /* Mjs */); + case ".cjs" /* Cjs */: + case ".cts" /* Cts */: + case ".d.cts" /* Dcts */: + return tryExtension(".cjs" /* Cjs */); + case ".json" /* Json */: + return tryExtension(".json" /* Json */); + default: + return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + } case Extensions.TSConfig: case Extensions.Json: return tryExtension(".json" /* Json */); @@ -42024,6 +42620,33 @@ var ts; var versionPaths = packageInfo && packageInfo.versionPaths; return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths)); } + /** + * A function for locating the package.json scope for a given path + */ + /*@internal*/ + function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) { + var state = { + host: host, + compilerOptions: options, + traceEnabled: isTraceEnabled(options, host), + failedLookupLocations: [], + packageJsonInfoCache: packageJsonInfoCache, + features: 0, + conditions: [], + }; + var parts = ts.getPathComponents(fileName); + parts.pop(); + while (parts.length > 0) { + var pkg = getPackageJsonInfo(ts.getPathFromPathComponents(parts), /*onlyRecordFailures*/ false, state); + if (pkg) { + return pkg; + } + parts.pop(); + } + return undefined; + } + ts.getPackageScopeForPath = getPackageScopeForPath; + /*@internal*/ function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { var _a, _b, _c; var host = state.host, traceEnabled = state.traceEnabled; @@ -42066,6 +42689,7 @@ var ts; state.failedLookupLocations.push(packageJsonPath); } } + ts.getPackageJsonInfo = getPackageJsonInfo; function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) { var packageFile; if (jsonContent) { @@ -42121,7 +42745,10 @@ var ts; var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state)); if (packageFileResult) return packageFileResult; - return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state); + // esm mode resolutions don't do package `index` lookups + if (!(state.features & NodeResolutionFeatures.EsmMode)) { + return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state); + } } /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ function resolvedIfExtensionMatches(extensions, path) { @@ -42151,6 +42778,234 @@ var ts; return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } ts.parsePackageName = parsePackageName; + /* @internal */ + function allKeysStartWithDot(obj) { + return ts.every(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); }); + } + ts.allKeysStartWithDot = allKeysStartWithDot; + function noKeyStartsWithDot(obj) { + return !ts.some(ts.getOwnKeys(obj), function (k) { return ts.startsWith(k, "."); }); + } + function loadModuleFromSelfNameReference(extensions, moduleName, directory, state, cache, redirectedReference) { + var _a, _b; + var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; + var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); + var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + if (!scope || !scope.packageJsonContent.exports) { + return undefined; + } + if (typeof scope.packageJsonContent.name !== "string") { + return undefined; + } + var parts = ts.getPathComponents(moduleName); // unrooted paths should have `""` as their 0th entry + var nameParts = ts.getPathComponents(scope.packageJsonContent.name); + if (!ts.every(nameParts, function (p, i) { return parts[i] === p; })) { + return undefined; + } + var trailingParts = parts.slice(nameParts.length); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + } + function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { + if (!scope.packageJsonContent.exports) { + return undefined; + } + if (subpath === ".") { + var mainExport = void 0; + if (typeof scope.packageJsonContent.exports === "string" || Array.isArray(scope.packageJsonContent.exports) || (typeof scope.packageJsonContent.exports === "object" && noKeyStartsWithDot(scope.packageJsonContent.exports))) { + mainExport = scope.packageJsonContent.exports; + } + else if (ts.hasProperty(scope.packageJsonContent.exports, ".")) { + mainExport = scope.packageJsonContent.exports["."]; + } + if (mainExport) { + var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false); + return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false); + } + } + else if (allKeysStartWithDot(scope.packageJsonContent.exports)) { + if (typeof scope.packageJsonContent.exports !== "object") { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory); + } + return toSearchResult(/*value*/ undefined); + } + var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, subpath, scope.packageJsonContent.exports, scope, /*isImports*/ false); + if (result) { + return result; + } + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Export_specifier_0_does_not_exist_in_package_json_scope_at_path_1, subpath, scope.packageDirectory); + } + return toSearchResult(/*value*/ undefined); + } + function loadModuleFromImports(extensions, moduleName, directory, state, cache, redirectedReference) { + var _a, _b; + if (moduleName === "#" || ts.startsWith(moduleName, "#/")) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Invalid_import_specifier_0_has_no_possible_resolutions, moduleName); + } + return toSearchResult(/*value*/ undefined); + } + var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; + var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); + var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + if (!scope) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath); + } + return toSearchResult(/*value*/ undefined); + } + if (!scope.packageJsonContent.imports) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_scope_0_has_no_imports_defined, scope.packageDirectory); + } + return toSearchResult(/*value*/ undefined); + } + var result = loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, scope.packageJsonContent.imports, scope, /*isImports*/ true); + if (result) { + return result; + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Import_specifier_0_does_not_exist_in_package_json_scope_at_path_1, moduleName, scope.packageDirectory); + } + return toSearchResult(/*value*/ undefined); + } + function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) { + var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports); + if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) { + var target = lookupTable[moduleName]; + return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false); + } + var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), function (a, b) { return a.length - b.length; }); + for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) { + var potentialTarget = expandingKeys_1[_i]; + if (state.features & NodeResolutionFeatures.ExportsPatternTrailers && matchesPatternWithTrailer(potentialTarget, moduleName)) { + var target = lookupTable[potentialTarget]; + var starPos = potentialTarget.indexOf("*"); + var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos)); + return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true); + } + else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) { + var target = lookupTable[potentialTarget]; + var subpath = moduleName.substring(potentialTarget.length - 1); + return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true); + } + else if (ts.startsWith(moduleName, potentialTarget)) { + var target = lookupTable[potentialTarget]; + var subpath = moduleName.substring(potentialTarget.length); + return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false); + } + } + function matchesPatternWithTrailer(target, name) { + if (ts.endsWith(target, "*")) + return false; // handled by next case in loop + var starPos = target.indexOf("*"); + if (starPos === -1) + return false; // handled by last case in loop + return ts.startsWith(name, target.substring(0, starPos)) && ts.endsWith(name, target.substring(starPos + 1)); + } + } + /** + * Gets the self-recursive function specialized to retrieving the targeted import/export element for the given resolution configuration + */ + function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) { + return loadModuleFromTargetImportOrExport; + function loadModuleFromTargetImportOrExport(target, subpath, pattern) { + var _a, _b; + if (typeof target === "string") { + if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); + } + return toSearchResult(/*value*/ undefined); + } + if (!ts.startsWith(target, "./")) { + if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) { + var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath; + var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference); + return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined); + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); + } + return toSearchResult(/*value*/ undefined); + } + var parts = ts.pathIsRelative(target) ? ts.getPathComponents(target).slice(1) : ts.getPathComponents(target); + var partsAfterFirst = parts.slice(1); + if (partsAfterFirst.indexOf("..") >= 0 || partsAfterFirst.indexOf(".") >= 0 || partsAfterFirst.indexOf("node_modules") >= 0) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); + } + return toSearchResult(/*value*/ undefined); + } + var resolvedTarget = ts.combinePaths(scope.packageDirectory, target); + // TODO: Assert that `resolvedTarget` is actually within the package directory? That's what the spec says.... but I'm not sure we need + // to be in the business of validating everyone's import and export map correctness. + var subpathParts = ts.getPathComponents(subpath); + if (subpathParts.indexOf("..") >= 0 || subpathParts.indexOf(".") >= 0 || subpathParts.indexOf("node_modules") >= 0) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); + } + return toSearchResult(/*value*/ undefined); + } + var finalPath = ts.getNormalizedAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)); + return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state))); + } + else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null + if (!Array.isArray(target)) { + for (var _i = 0, _c = ts.getOwnKeys(target); _i < _c.length; _i++) { + var key = _c[_i]; + if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) { + var subTarget = target[key]; + var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern); + if (result) { + return result; + } + } + } + return undefined; + } + else { + if (!ts.length(target)) { + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); + } + return toSearchResult(/*value*/ undefined); + } + for (var _d = 0, target_1 = target; _d < target_1.length; _d++) { + var elem = target_1[_d]; + var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern); + if (result) { + return result; + } + } + } + } + else if (target === null) { // eslint-disable-line no-null/no-null + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_scope_0_explicitly_maps_specifier_1_to_null, scope.packageDirectory, moduleName); + } + return toSearchResult(/*value*/ undefined); + } + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); + } + return toSearchResult(/*value*/ undefined); + } + } + /* @internal */ + function isApplicableVersionedTypesKey(conditions, key) { + if (conditions.indexOf("types") === -1) + return false; // only apply versioned types conditions if the types condition is applied + if (!ts.startsWith(key, "types@")) + return false; + var range = ts.VersionRange.tryParse(key.substring("types@".length)); + if (!range) + return false; + return range.test(ts.version); + } + ts.isApplicableVersionedTypesKey = isApplicableVersionedTypesKey; function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) { return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, /*typesScopeOnly*/ false, cache, redirectedReference); } @@ -42159,24 +43014,24 @@ var ts; return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, /*typesScopeOnly*/ true, /*cache*/ undefined, /*redirectedReference*/ undefined); } function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) { - var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); + var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, state.features === 0 ? undefined : state.features & NodeResolutionFeatures.EsmMode ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS, redirectedReference); return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state); if (resolutionFromCache) { return resolutionFromCache; } - return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly)); + return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly, cache, redirectedReference)); } }); } - function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) { + function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) { var nodeModulesFolder = ts.combinePaths(directory, "node_modules"); var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host); if (!nodeModulesFolderExists && state.traceEnabled) { trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder); } - var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state); + var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state, cache, redirectedReference); if (packageResult) { return packageResult; } @@ -42189,27 +43044,35 @@ var ts; } nodeModulesAtTypesExists = false; } - return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state); + return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state, cache, redirectedReference); } } - function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) { + function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) { var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName)); // First look for a nested package.json, as in `node_modules/foo/bar/package.json`. var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state); - if (packageInfo) { - var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state); - if (fromFile) { - return noPackageId(fromFile); + // But only if we're not respecting export maps (if we are, we might redirect around this location) + if (!(state.features & NodeResolutionFeatures.Exports)) { + if (packageInfo) { + var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state); + if (fromFile) { + return noPackageId(fromFile); + } + var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths); + return withPackageId(packageInfo, fromDirectory); } - var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths); - return withPackageId(packageInfo, fromDirectory); } + var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest; var loader = function (extensions, candidate, onlyRecordFailures, state) { + var _a; + // package exports are higher priority than file/directory lookups (and, if there's exports present, blocks them) + if (packageInfo && packageInfo.packageJsonContent.exports && state.features & NodeResolutionFeatures.Exports) { + return (_a = loadModuleFromExports(packageInfo, extensions, ts.combinePaths(".", rest), state, cache, redirectedReference)) === null || _a === void 0 ? void 0 : _a.value; + } var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) || loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths); return withPackageId(packageInfo, pathAndExtension); }; - var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest; if (rest !== "") { // If "rest" is empty, we just did this search above. var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName); // Don't use a "types" or "main" from here because we're not loading the root, but a subdirectory -- just here for the packageId and path mappings. @@ -42311,7 +43174,7 @@ var ts; function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) { var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] }; var containingDirectory = ts.getDirectoryPath(containingFile); var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath @@ -42322,7 +43185,7 @@ var ts; return { value: resolvedUsingSettings }; } if (!ts.isExternalModuleNameRelative(moduleName)) { - var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference); + var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, /*mode*/ undefined, redirectedReference); // Climb up parent directories looking for a module. var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) { var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state); @@ -42358,8 +43221,8 @@ var ts; trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache }; - var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false); + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [] }; + var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; @@ -42404,26 +43267,26 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 256 /* InterfaceDeclaration */: - case 257 /* TypeAliasDeclaration */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 264 /* ImportDeclaration */: - case 263 /* ImportEqualsDeclaration */: + case 265 /* ImportDeclaration */: + case 264 /* 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 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 271 /* NamedExports */) { + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 272 /* NamedExports */) { var state = 0 /* NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -42439,7 +43302,7 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 260 /* ModuleBlock */: { + case 261 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); @@ -42461,7 +43324,7 @@ var ts; }); return state_1; } - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return getModuleInstanceState(node, visited); case 79 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -42525,7 +43388,7 @@ var ts; ContainerFlags[ContainerFlags["IsFunctionExpression"] = 16] = "IsFunctionExpression"; ContainerFlags[ContainerFlags["HasLocals"] = 32] = "HasLocals"; ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; - ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; + ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethodOrAccessor"] = 128] = "IsObjectLiteralOrClassExpressionMethodOrAccessor"; })(ContainerFlags || (ContainerFlags = {})); function initFlowNode(node) { ts.Debug.attachFlowNodeDebugInfo(node); @@ -42662,7 +43525,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 === 269 /* ExportAssignment */) { + if (node.kind === 270 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -42671,7 +43534,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 160 /* ComputedPropertyName */) { + if (name.kind === 161 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -42697,36 +43560,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 169 /* Constructor */: + case 170 /* Constructor */: return "__constructor" /* Constructor */; - case 177 /* FunctionType */: - case 172 /* CallSignature */: - case 318 /* JSDocSignature */: + case 178 /* FunctionType */: + case 173 /* CallSignature */: + case 321 /* JSDocSignature */: return "__call" /* Call */; - case 178 /* ConstructorType */: - case 173 /* ConstructSignature */: + case 179 /* ConstructorType */: + case 174 /* ConstructSignature */: return "__new" /* New */; - case 174 /* IndexSignature */: + case 175 /* IndexSignature */: return "__index" /* Index */; - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 300 /* SourceFile */: + case 303 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 312 /* JSDocFunctionType */: + case 315 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 162 /* Parameter */: + case 163 /* 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 === 312 /* 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 === 315 /* 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; @@ -42828,7 +43691,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 === 269 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 270 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -42867,7 +43730,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 273 /* ExportSpecifier */ || (node.kind === 263 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 274 /* ExportSpecifier */ || (node.kind === 264 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -42956,7 +43819,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 !== 212 /* ArrowFunction */) { + if (node.kind !== 213 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -42983,13 +43846,13 @@ var ts; // similarly to break statements that exit to a label just past the statement body. if (!isIIFE) { currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { + if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // 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 === 169 /* Constructor */ || node.kind === 168 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 254 /* FunctionDeclaration */ || node.kind === 211 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 170 /* Constructor */ || node.kind === 169 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 255 /* FunctionDeclaration */ || node.kind === 212 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -43004,14 +43867,14 @@ var ts; node.flags |= 512 /* HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 300 /* SourceFile */) { + if (node.kind === 303 /* SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 169 /* Constructor */ || node.kind === 168 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 254 /* FunctionDeclaration */ || node.kind === 211 /* FunctionExpression */))) { + if (node.kind === 170 /* Constructor */ || node.kind === 169 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 255 /* FunctionDeclaration */ || node.kind === 212 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -43038,8 +43901,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 254 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 254 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 255 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 255 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -43062,59 +43925,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 235 /* FirstStatement */ && node.kind <= 251 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 236 /* FirstStatement */ && node.kind <= 252 /* LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 239 /* WhileStatement */: + case 240 /* WhileStatement */: bindWhileStatement(node); break; - case 238 /* DoStatement */: + case 239 /* DoStatement */: bindDoStatement(node); break; - case 240 /* ForStatement */: + case 241 /* ForStatement */: bindForStatement(node); break; - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 237 /* IfStatement */: + case 238 /* IfStatement */: bindIfStatement(node); break; - case 245 /* ReturnStatement */: - case 249 /* ThrowStatement */: + case 246 /* ReturnStatement */: + case 250 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 244 /* BreakStatement */: - case 243 /* ContinueStatement */: + case 245 /* BreakStatement */: + case 244 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 250 /* TryStatement */: + case 251 /* TryStatement */: bindTryStatement(node); break; - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: bindSwitchStatement(node); break; - case 261 /* CaseBlock */: + case 262 /* CaseBlock */: bindCaseBlock(node); break; - case 287 /* CaseClause */: + case 288 /* CaseClause */: bindCaseClause(node); break; - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: bindExpressionStatement(node); break; - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: bindLabeledStatement(node); break; - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 218 /* PostfixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -43124,47 +43987,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 213 /* DeleteExpression */: + case 214 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 206 /* CallExpression */: + case 207 /* CallExpression */: bindCallExpressionFlow(node); break; - case 228 /* NonNullExpression */: + case 229 /* NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 340 /* JSDocTypedefTag */: - case 333 /* JSDocCallbackTag */: - case 334 /* JSDocEnumTag */: + case 343 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: + case 337 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 300 /* SourceFile */: { + case 303 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 233 /* Block */: - case 260 /* ModuleBlock */: + case 234 /* Block */: + case 261 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 201 /* BindingElement */: + case 202 /* BindingElement */: bindBindingElementFlow(node); break; - case 203 /* ObjectLiteralExpression */: - case 202 /* ArrayLiteralExpression */: - case 291 /* PropertyAssignment */: - case 223 /* SpreadElement */: + case 204 /* ObjectLiteralExpression */: + case 203 /* ArrayLiteralExpression */: + case 294 /* PropertyAssignment */: + case 224 /* 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; @@ -43181,19 +44044,19 @@ var ts; case 79 /* Identifier */: case 80 /* PrivateIdentifier */: case 108 /* ThisKeyword */: - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: return containsNarrowableReference(expr); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return hasNarrowableArgument(expr); - case 210 /* ParenthesizedExpression */: - case 228 /* NonNullExpression */: + case 211 /* ParenthesizedExpression */: + case 229 /* NonNullExpression */: return isNarrowingExpression(expr.expression); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 214 /* TypeOfExpression */: + case 215 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -43217,7 +44080,7 @@ var ts; } } } - if (expr.expression.kind === 204 /* PropertyAccessExpression */ && + if (expr.expression.kind === 205 /* PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -43250,9 +44113,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 63 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -43328,26 +44191,26 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 237 /* IfStatement */: - case 239 /* WhileStatement */: - case 238 /* DoStatement */: + case 238 /* IfStatement */: + case 240 /* WhileStatement */: + case 239 /* DoStatement */: return parent.expression === node; - case 240 /* ForStatement */: - case 220 /* ConditionalExpression */: + case 241 /* ForStatement */: + case 221 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 210 /* ParenthesizedExpression */) { + if (node.kind === 211 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 217 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 218 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 219 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + return node.kind === 220 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */); } @@ -43394,7 +44257,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 248 /* LabeledStatement */) { + while (label && node.parent.kind === 249 /* LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -43445,12 +44308,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 242 /* ForOfStatement */) { + if (node.kind === 243 /* ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 253 /* VariableDeclarationList */) { + if (node.initializer.kind !== 254 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -43472,7 +44335,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 245 /* ReturnStatement */) { + if (node.kind === 246 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -43489,7 +44352,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 244 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 245 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -43594,7 +44457,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 288 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 289 /* 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. @@ -43642,7 +44505,7 @@ 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 === 206 /* CallExpression */) { + if (node.kind === 207 /* CallExpression */) { var call = node; if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); @@ -43668,7 +44531,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 219 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 220 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -43679,10 +44542,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); } - else if (node.kind === 202 /* ArrayLiteralExpression */) { + else if (node.kind === 203 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 223 /* SpreadElement */) { + if (e.kind === 224 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -43690,16 +44553,16 @@ var ts; } } } - else if (node.kind === 203 /* ObjectLiteralExpression */) { + else if (node.kind === 204 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 291 /* PropertyAssignment */) { + if (p.kind === 294 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 292 /* ShorthandPropertyAssignment */) { + else if (p.kind === 295 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 293 /* SpreadAssignment */) { + else if (p.kind === 296 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -43831,7 +44694,7 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 205 /* ElementAccessExpression */) { + if (operator === 63 /* EqualsToken */ && node.left.kind === 206 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -43859,7 +44722,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 204 /* PropertyAccessExpression */) { + if (node.expression.kind === 205 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -43916,7 +44779,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 334 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 337 /* 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); @@ -43928,7 +44791,7 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 167 /* MethodDeclaration */) { + if (host && host.kind !== 168 /* MethodDeclaration */) { addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } } @@ -43941,15 +44804,15 @@ var ts; } function bindOptionalChainRest(node) { switch (node.kind) { - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 206 /* CallExpression */: + case 207 /* CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -44014,7 +44877,7 @@ 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 === 211 /* FunctionExpression */ || expr.kind === 212 /* ArrowFunction */) { + if (expr.kind === 212 /* FunctionExpression */ || expr.kind === 213 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -44026,7 +44889,7 @@ var ts; } } } - if (node.expression.kind === 204 /* PropertyAccessExpression */) { + if (node.expression.kind === 205 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -44035,55 +44898,55 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 224 /* ClassExpression */: - case 255 /* ClassDeclaration */: - case 258 /* EnumDeclaration */: - case 203 /* ObjectLiteralExpression */: - case 180 /* TypeLiteral */: - case 317 /* JSDocTypeLiteral */: - case 284 /* JsxAttributes */: + case 225 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 259 /* EnumDeclaration */: + case 204 /* ObjectLiteralExpression */: + case 181 /* TypeLiteral */: + case 320 /* JSDocTypeLiteral */: + case 285 /* JsxAttributes */: return 1 /* IsContainer */; - case 256 /* InterfaceDeclaration */: + case 257 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 259 /* ModuleDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 193 /* MappedType */: + case 260 /* ModuleDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 194 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 300 /* SourceFile */: + case 303 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 167 /* MethodDeclaration */: - if (ts.isObjectLiteralOrClassExpressionMethod(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 168 /* MethodDeclaration */: + if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { + return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - 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 */: + case 170 /* Constructor */: + case 255 /* FunctionDeclaration */: + case 167 /* MethodSignature */: + case 173 /* CallSignature */: + case 321 /* JSDocSignature */: + case 315 /* JSDocFunctionType */: + case 178 /* FunctionType */: + case 174 /* ConstructSignature */: + case 175 /* IndexSignature */: + case 179 /* ConstructorType */: + case 169 /* ClassStaticBlockDeclaration */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 260 /* ModuleBlock */: + case 261 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 290 /* CatchClause */: - case 240 /* ForStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: - case 261 /* CaseBlock */: + case 291 /* CatchClause */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 262 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 233 /* Block */: + case 234 /* 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 @@ -44116,46 +44979,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 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 300 /* SourceFile */: + case 303 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 224 /* ClassExpression */: - case 255 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 256 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 180 /* TypeLiteral */: - case 317 /* JSDocTypeLiteral */: - case 203 /* ObjectLiteralExpression */: - case 256 /* InterfaceDeclaration */: - case 284 /* JsxAttributes */: + case 181 /* TypeLiteral */: + case 320 /* JSDocTypeLiteral */: + case 204 /* ObjectLiteralExpression */: + case 257 /* InterfaceDeclaration */: + case 285 /* 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 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 */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 321 /* JSDocSignature */: + case 175 /* IndexSignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 315 /* JSDocFunctionType */: + case 343 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: + case 169 /* ClassStaticBlockDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 194 /* 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 @@ -44254,7 +45117,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 === 293 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { + if (prop.kind === 296 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { continue; } var identifier = prop.name; @@ -44266,7 +45129,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 === 291 /* PropertyAssignment */ || prop.kind === 292 /* ShorthandPropertyAssignment */ || prop.kind === 167 /* MethodDeclaration */ + var currentKind = prop.kind === 294 /* PropertyAssignment */ || prop.kind === 295 /* ShorthandPropertyAssignment */ || prop.kind === 168 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -44298,10 +45161,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 300 /* SourceFile */: + case 303 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -44398,7 +45261,7 @@ var ts; node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 131 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* 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))); } @@ -44500,8 +45363,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 300 /* SourceFile */ && - blockScopeContainer.kind !== 259 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 303 /* SourceFile */ && + blockScopeContainer.kind !== 260 /* 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. @@ -44540,7 +45403,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && options.target >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -44596,7 +45459,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 > 158 /* LastToken */) { + if (node.kind > 159 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -44672,23 +45535,23 @@ var ts; } // falls through case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 292 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 295 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 229 /* MetaProperty */: + case 230 /* MetaProperty */: case 106 /* SuperKeyword */: node.flowNode = currentFlow; break; case 80 /* PrivateIdentifier */: return checkPrivateIdentifier(node); - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -44703,7 +45566,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -44739,78 +45602,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 290 /* CatchClause */: + case 291 /* CatchClause */: return checkStrictModeCatchClause(node); - case 213 /* DeleteExpression */: + case 214 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 218 /* PostfixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 246 /* WithStatement */: + case 247 /* WithStatement */: return checkStrictModeWithStatement(node); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 190 /* ThisType */: + case 191 /* ThisType */: seenThisKeyword = true; return; - case 175 /* TypePredicate */: + case 176 /* TypePredicate */: break; // Binding the children will handle everything - case 161 /* TypeParameter */: + case 162 /* TypeParameter */: return bindTypeParameter(node); - case 162 /* Parameter */: + case 163 /* Parameter */: return bindParameter(node); - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 201 /* BindingElement */: + case 202 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: return bindPropertyWorker(node); - case 291 /* PropertyAssignment */: - case 292 /* ShorthandPropertyAssignment */: + case 294 /* PropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 294 /* EnumMember */: + case 297 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 172 /* CallSignature */: - case 173 /* ConstructSignature */: - case 174 /* IndexSignature */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 175 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 168 /* MethodDeclaration */: + case 167 /* 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 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 169 /* Constructor */: + case 170 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 170 /* GetAccessor */: + case 171 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 171 /* SetAccessor */: + case 172 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 177 /* FunctionType */: - case 312 /* JSDocFunctionType */: - case 318 /* JSDocSignature */: - case 178 /* ConstructorType */: + case 178 /* FunctionType */: + case 315 /* JSDocFunctionType */: + case 321 /* JSDocSignature */: + case 179 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 180 /* TypeLiteral */: - case 317 /* JSDocTypeLiteral */: - case 193 /* MappedType */: + case 181 /* TypeLiteral */: + case 320 /* JSDocTypeLiteral */: + case 194 /* MappedType */: return bindAnonymousTypeWorker(node); - case 327 /* JSDocClassTag */: + case 330 /* JSDocClassTag */: return bindJSDocClassTag(node); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return bindFunctionExpression(node); - case 206 /* CallExpression */: + case 207 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -44829,65 +45692,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 224 /* ClassExpression */: - case 255 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 256 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 256 /* InterfaceDeclaration */: + case 257 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 257 /* TypeAliasDeclaration */: + case 258 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 284 /* JsxAttributes */: + case 285 /* JsxAttributes */: return bindJsxAttributes(node); - case 283 /* JsxAttribute */: + case 284 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 263 /* ImportEqualsDeclaration */: - case 266 /* NamespaceImport */: - case 268 /* ImportSpecifier */: - case 273 /* ExportSpecifier */: + case 264 /* ImportEqualsDeclaration */: + case 267 /* NamespaceImport */: + case 269 /* ImportSpecifier */: + case 274 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 262 /* NamespaceExportDeclaration */: + case 263 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 265 /* ImportClause */: + case 266 /* ImportClause */: return bindImportClause(node); - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: return bindExportDeclaration(node); - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: return bindExportAssignment(node); - case 300 /* SourceFile */: + case 303 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 233 /* Block */: + case 234 /* Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 260 /* ModuleBlock */: + case 261 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 335 /* JSDocParameterTag */: - if (node.parent.kind === 318 /* JSDocSignature */) { + case 338 /* JSDocParameterTag */: + if (node.parent.kind === 321 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 317 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 320 /* JSDocTypeLiteral */) { break; } // falls through - case 342 /* JSDocPropertyTag */: + case 345 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 311 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 314 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 340 /* JSDocTypedefTag */: - case 333 /* JSDocCallbackTag */: - case 334 /* JSDocEnumTag */: + case 343 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: + case 337 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -45050,8 +45913,8 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 212 /* 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 === 63 /* EqualsToken */) { @@ -45073,11 +45936,12 @@ var ts; addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 169 /* Constructor */: - case 165 /* PropertyDeclaration */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 170 /* Constructor */: + case 166 /* PropertyDeclaration */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 169 /* ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -45089,7 +45953,7 @@ var ts; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); } break; - case 300 /* SourceFile */: + case 303 /* 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; @@ -45118,7 +45982,7 @@ var ts; if (node.expression.kind === 108 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 300 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 303 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -45158,7 +46022,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 300 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 303 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -45267,8 +46131,8 @@ var ts; } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 300 /* SourceFile */ - : propertyAccess.parent.parent.kind === 300 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 303 /* SourceFile */ + : propertyAccess.parent.parent.kind === 303 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -45347,7 +46211,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 255 /* ClassDeclaration */) { + if (node.kind === 256 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -45413,7 +46277,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 335 /* JSDocParameterTag */ && container.kind !== 318 /* JSDocSignature */) { + if (node.kind === 338 /* JSDocParameterTag */ && container.kind !== 321 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { @@ -45466,7 +46330,7 @@ var ts; if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { emitFlags |= 2048 /* HasAsyncFunctions */; } - if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { + if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) @@ -45479,7 +46343,7 @@ var ts; } function bindTypeParameter(node) { if (ts.isJSDocTemplateTag(node.parent)) { - var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent); // TODO: GH#18217 + var container_1 = ts.getEffectiveContainerForJSDocTemplateTag(node.parent); if (container_1) { if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); @@ -45490,7 +46354,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 188 /* InferType */) { + else if (node.parent.kind === 189 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -45518,11 +46382,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 234 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 235 /* EmptyStatement */) || // report error on class declarations - node.kind === 255 /* ClassDeclaration */ || + node.kind === 256 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 259 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 260 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -45566,12 +46430,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 256 /* InterfaceDeclaration */: - case 257 /* TypeAliasDeclaration */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: return true; - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: return ts.hasSyntacticModifier(s, 2048 /* Const */); default: return false; @@ -45771,7 +46635,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 === 179 /* TypeQuery */) { + if (d.type && d.type.kind === 180 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -45958,6 +46822,13 @@ var ts; IntersectionState[IntersectionState["UnionIntersectionCheck"] = 8] = "UnionIntersectionCheck"; IntersectionState[IntersectionState["InPropertyCheck"] = 16] = "InPropertyCheck"; })(IntersectionState || (IntersectionState = {})); + var RecursionFlags; + (function (RecursionFlags) { + RecursionFlags[RecursionFlags["None"] = 0] = "None"; + RecursionFlags[RecursionFlags["Source"] = 1] = "Source"; + RecursionFlags[RecursionFlags["Target"] = 2] = "Target"; + RecursionFlags[RecursionFlags["Both"] = 3] = "Both"; + })(RecursionFlags || (RecursionFlags = {})); var MappedTypeModifiers; (function (MappedTypeModifiers) { MappedTypeModifiers[MappedTypeModifiers["IncludeReadonly"] = 1] = "IncludeReadonly"; @@ -46047,17 +46918,21 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host, produceDiagnostics) { - var getPackagesSet = ts.memoize(function () { - var set = new ts.Set(); + var getPackagesMap = ts.memoize(function () { + // A package name maps to true when we detect it has .d.ts files. + // This is useful as an approximation of whether a package bundles its own types. + // Note: we only look at files already found by module resolution, + // so there may be files we did not consider. + var map = new ts.Map(); host.getSourceFiles().forEach(function (sf) { if (!sf.resolvedModules) return; - ts.forEachEntry(sf.resolvedModules, function (r) { + sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - set.add(r.packageId.name); + map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); }); }); - return set; + return map; }); // Cancellation that controls whether or not we can cancel in the middle of type checking. // In general cancelling is *not* safe for the type checker. We might be in the middle of @@ -46080,6 +46955,7 @@ var ts; var totalInstantiationCount = 0; var instantiationCount = 0; var instantiationDepth = 0; + var inlineLevel = 0; var currentNode; var emptySymbols = ts.createSymbolTable(); var arrayVariances = [1 /* Covariant */]; @@ -46365,11 +47241,14 @@ var ts; getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, getOptionalType: function () { return optionalType; }, + getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); }, + getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); }, isSymbolAccessible: isSymbolAccessible, isArrayType: isArrayType, isTupleType: isTupleType, isArrayLikeType: isArrayLikeType, isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant, + getExactOptionalProperties: getExactOptionalProperties, getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestedSymbolForNonexistentProperty: getSuggestedSymbolForNonexistentProperty, getSuggestionForNonexistentProperty: getSuggestionForNonexistentProperty, @@ -46441,6 +47320,9 @@ var ts; }, getLocalTypeParametersOfClassOrInterfaceOrTypeAlias: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias, isDeclarationVisible: isDeclarationVisible, + isPropertyAccessible: isPropertyAccessible, + getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration, + getMemberOverrideModifierStatus: getMemberOverrideModifierStatus, }; function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) { var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); @@ -46465,13 +47347,17 @@ var ts; var undefinedProperties = new ts.Map(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unresolvedSymbols = new ts.Map(); + var errorTypes = new ts.Map(); var anyType = createIntrinsicType(1 /* Any */, "any"); var autoType = createIntrinsicType(1 /* Any */, "any"); var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */); var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 131072 /* ContainsWideningType */); var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); @@ -46620,8 +47506,10 @@ var ts; var deferredGlobalTemplateStringsArrayType; var deferredGlobalImportMetaType; var deferredGlobalImportMetaExpressionType; + var deferredGlobalImportCallOptionsType; var deferredGlobalExtractSymbol; var deferredGlobalOmitSymbol; + var deferredGlobalAwaitedSymbol; var deferredGlobalBigIntType; var allPotentiallyUnusedIdentifiers = new ts.Map(); // key is file name var flowLoopStart = 0; @@ -46678,6 +47566,21 @@ var ts; var enumRelation = new ts.Map(); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); + // Extensions suggested for path imports when module resolution is node12 or higher. + // The first element of each tuple is the extension a file has. + // The second element of each tuple is the extension that should be used in a path import. + // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs". + var suggestedExtensions = [ + [".mts", ".mjs"], + [".ts", ".js"], + [".cts", ".cjs"], + [".mjs", ".mjs"], + [".js", ".js"], + [".cjs", ".cjs"], + [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".jsx", ".jsx"], + [".json", ".json"], + ]; initializeTypeChecker(); return checker; function getJsxNamespace(location) { @@ -46704,17 +47607,9 @@ var ts; } } else { - if (file.localJsxNamespace) { - return file.localJsxNamespace; - } - var jsxPragma = file.pragmas.get("jsx"); - if (jsxPragma) { - var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; - file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion); - ts.visitNode(file.localJsxFactory, markAsSynthetic); - if (file.localJsxFactory) { - return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText; - } + var localJsxNamespace = getLocalJsxNamespace(file); + if (localJsxNamespace) { + return file.localJsxNamespace = localJsxNamespace; } } } @@ -46736,10 +47631,24 @@ var ts; _jsxFactoryEntity = ts.factory.createQualifiedName(ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement"); } return _jsxNamespace; - function markAsSynthetic(node) { - ts.setTextRangePosEnd(node, -1, -1); - return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext); + } + function getLocalJsxNamespace(file) { + if (file.localJsxNamespace) { + return file.localJsxNamespace; } + var jsxPragma = file.pragmas.get("jsx"); + if (jsxPragma) { + var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; + file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion); + ts.visitNode(file.localJsxFactory, markAsSynthetic); + if (file.localJsxFactory) { + return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText; + } + } + } + function markAsSynthetic(node) { + ts.setTextRangePosEnd(node, -1, -1); + return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext); } function getEmitResolver(sourceFile, cancellationToken) { // Ensure we have all the type information in place for this file so that all the @@ -47104,7 +48013,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 300 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 303 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -47163,17 +48072,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 === 201 /* BindingElement */) { + if (declaration.kind === 202 /* 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, 201 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 202 /* 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, 252 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 253 /* VariableDeclaration */), usage); } - else if (declaration.kind === 252 /* VariableDeclaration */) { + else if (declaration.kind === 253 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -47187,7 +48096,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -47203,19 +48112,19 @@ 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 === 273 /* ExportSpecifier */ || (usage.parent.kind === 269 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 274 /* ExportSpecifier */ || (usage.parent.kind === 270 /* 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 === 269 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 270 /* ExportAssignment */ && usage.isExportEquals) { return true; } if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -47230,9 +48139,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 235 /* VariableStatement */: - case 240 /* ForStatement */: - case 242 /* ForOfStatement */: + case 236 /* VariableStatement */: + case 241 /* ForStatement */: + case 243 /* 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)) { @@ -47260,7 +48169,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 167 /* MethodDeclaration */) { + if (declaration.kind === 168 /* MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -47275,7 +48184,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 165 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 166 /* PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -47298,19 +48207,19 @@ var ts; return "quit"; } switch (node.kind) { - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return true; - case 165 /* PropertyDeclaration */: + case 166 /* 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 233 /* Block */: + case 234 /* Block */: switch (node.parent.kind) { - case 170 /* GetAccessor */: - case 167 /* MethodDeclaration */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 168 /* MethodDeclaration */: + case 172 /* SetAccessor */: return true; default: return false; @@ -47350,18 +48259,18 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 212 /* ArrowFunction */: - case 211 /* FunctionExpression */: - case 254 /* FunctionDeclaration */: - case 169 /* Constructor */: + case 213 /* ArrowFunction */: + case 212 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 170 /* Constructor */: // do not descend into these return false; - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 291 /* PropertyAssignment */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 294 /* PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { return target < 99 /* ESNext */ || !useDefineForClassFields; @@ -47388,12 +48297,12 @@ var ts; * * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters. */ - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, issueSuggestions) { + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals) { if (excludeGlobals === void 0) { excludeGlobals = false; } - return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, issueSuggestions); + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol); } - function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, issueSuggestions) { - var _a; + function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup) { + var _a, _b, _c; var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location var result; var lastLocation; @@ -47416,12 +48325,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 !== 315 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 318 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 162 /* Parameter */ || - lastLocation.kind === 161 /* TypeParameter */ + lastLocation.kind === 163 /* Parameter */ || + lastLocation.kind === 162 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -47436,13 +48345,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 === 162 /* Parameter */ || + lastLocation.kind === 163 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 187 /* ConditionalType */) { + else if (location.kind === 188 /* 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; @@ -47457,14 +48366,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 300 /* SourceFile */: + case 303 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 259 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports || emptySymbols; - if (location.kind === 300 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + case 260 /* ModuleDeclaration */: + var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; + if (location.kind === 303 /* 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 */)) { @@ -47488,13 +48397,13 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 273 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 272 /* NamespaceExport */))) { + (ts.getDeclarationOfKind(moduleExport, 274 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 273 /* NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { - if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_a = result.declarations) === null || _a === void 0 ? void 0 : _a.some(ts.isJSDocTypeAlias))) { + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } else { @@ -47502,12 +48411,12 @@ var ts; } } break; - case 258 /* EnumDeclaration */: - if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { + case 259 /* EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 165 /* PropertyDeclaration */: + case 166 /* 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 @@ -47524,9 +48433,9 @@ var ts; } } break; - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: - case 256 /* InterfaceDeclaration */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* 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! @@ -47545,7 +48454,7 @@ var ts; } break loop; } - if (location.kind === 224 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 225 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -47553,7 +48462,7 @@ var ts; } } break; - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { var container = location.parent.parent; @@ -47573,9 +48482,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 256 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 257 /* 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); @@ -47583,24 +48492,24 @@ var ts; } } break; - case 212 /* ArrowFunction */: + case 213 /* 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 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { break; } // falls through - case 167 /* MethodDeclaration */: - case 169 /* Constructor */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 254 /* FunctionDeclaration */: + case 168 /* MethodDeclaration */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 255 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -47613,7 +48522,7 @@ var ts; } } break; - case 163 /* Decorator */: + case 164 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -47622,7 +48531,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 === 162 /* Parameter */) { + if (location.parent && location.parent.kind === 163 /* Parameter */) { location = location.parent; } // @@ -47637,20 +48546,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 === 255 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 256 /* ClassDeclaration */)) { location = location.parent; } break; - case 340 /* JSDocTypedefTag */: - case 333 /* JSDocCallbackTag */: - case 334 /* JSDocEnumTag */: + case 343 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: + case 337 /* 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 162 /* Parameter */: + case 163 /* Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -47658,7 +48567,7 @@ var ts; } } break; - case 201 /* BindingElement */: + case 202 /* BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -47666,7 +48575,7 @@ var ts; } } break; - case 188 /* InferType */: + case 189 /* InferType */: if (meaning & 262144 /* TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { @@ -47680,7 +48589,9 @@ var ts; lastSelfReferenceLocation = location; } lastLocation = location; - location = location.parent; + location = ts.isJSDocTemplateTag(location) ? + ts.getEffectiveContainerForJSDocTemplateTag(location) || location.parent : + location.parent; } // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`. // If `result === lastSelfReferenceLocation.symbol`, that means that we are somewhere inside `lastSelfReferenceLocation` looking up a name, and resolving to `lastLocation` itself. @@ -47690,7 +48601,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 300 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 303 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -47717,7 +48628,7 @@ var ts; !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { var suggestion = void 0; - if (issueSuggestions && suggestionCount < maximumSuggestionCount) { + if (suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); if (isGlobalScopeAugmentationDeclaration) { @@ -47726,7 +48637,9 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); 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 message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + : 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) { @@ -47752,7 +48665,7 @@ var ts; } // Perform extra checks only if error reporting was requested if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { // We have a match, but the reference occurred within a property initializer and the identifier also binds // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed // with ESNext+useDefineForClassFields because the scope semantics are different. @@ -47809,23 +48722,24 @@ var ts; if (!ts.isValidTypeOnlyAliasUseSite(useSite)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol); if (typeOnlyDeclaration) { - var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); - var message = isExport + var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; - var relatedMessage = isExport - ? ts.Diagnostics._0_was_exported_here - : ts.Diagnostics._0_was_imported_here; var unescapedName = ts.unescapeLeadingUnderscores(name); - ts.addRelatedInfo(error(useSite, message, unescapedName), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, unescapedName)); + addTypeOnlyDeclarationRelatedInfo(error(useSite, message, unescapedName), typeOnlyDeclaration, unescapedName); } } } + function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { + if (!typeOnlyDeclaration) + return diagnostic; + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 274 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 212 /* ArrowFunction */ && location.kind !== 211 /* FunctionExpression */) { + if (location.kind !== 213 /* ArrowFunction */ && location.kind !== 212 /* 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 === 165 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 166 /* 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; @@ -47838,12 +48752,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 254 /* FunctionDeclaration */: - case 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: - case 258 /* EnumDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 259 /* ModuleDeclaration */: // For `namespace N { N; }` + case 255 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 259 /* EnumDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 260 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -47856,7 +48770,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 161 /* TypeParameter */) { + if (decl.kind === 162 /* 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 @@ -47913,9 +48827,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 79 /* Identifier */: - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -47959,7 +48873,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 === 273 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 274 /* ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } @@ -48035,7 +48949,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 === 258 /* 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 === 259 /* EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -48070,13 +48984,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return node; - case 265 /* ImportClause */: + case 266 /* ImportClause */: return node.parent; - case 266 /* NamespaceImport */: + case 267 /* NamespaceImport */: return node.parent.parent; - case 268 /* ImportSpecifier */: + case 269 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -48101,22 +49015,22 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(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) + return node.kind === 264 /* ImportEqualsDeclaration */ + || node.kind === 263 /* NamespaceExportDeclaration */ + || node.kind === 266 /* ImportClause */ && !!node.name + || node.kind === 267 /* NamespaceImport */ + || node.kind === 273 /* NamespaceExport */ + || node.kind === 269 /* ImportSpecifier */ + || node.kind === 274 /* ExportSpecifier */ + || node.kind === 270 /* 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 === 63 /* EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 292 /* ShorthandPropertyAssignment */ - || node.kind === 291 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 295 /* ShorthandPropertyAssignment */ + || node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) || ts.isRequireVariableDeclaration(node); } function isAliasableOrJsExpression(e) { @@ -48130,7 +49044,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 275 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 276 /* ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -48143,15 +49057,13 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration); + var isExport = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; var relatedMessage = isExport ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here; - // Non-null assertion is safe because the optionality comes from ImportClause, - // but if an ImportClause was the typeOnlyDeclaration, it had to have a `name`. var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText); ts.addRelatedInfo(error(node.moduleReference, message), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name)); } @@ -48166,7 +49078,25 @@ var ts; function isSyntacticDefault(node) { return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); } - function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) { + function getUsageModeForExpression(usage) { + return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; + } + function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) { + return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS; + } + function isOnlyImportedAsDefault(usage) { + var usageMode = getUsageModeForExpression(usage); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + } + function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { + var usageMode = file && getUsageModeForExpression(usage); + if (file && usageMode !== undefined) { + var result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat); + if (usageMode === ts.ModuleKind.ESNext || result) { + return result; + } + // fallthrough on cjs usages so we imply defaults for interop'd imports, too + } if (!allowSyntheticDefaultImports) { return false; } @@ -48208,8 +49138,9 @@ var ts; exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); - var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias); - if (!exportDefaultSymbol && !hasSyntheticDefault) { + var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); + var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier); + if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); @@ -48223,7 +49154,7 @@ var ts; reportNonDefaultExport(moduleSymbol, node); } } - else if (hasSyntheticDefault) { + else if (hasSyntheticDefault || hasDefaultOnly) { // per emit behavior, a synthetic default overrides a "real" .default member if `__esModule` is not present var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, /*overwriteTypeOnly*/ false); @@ -48328,7 +49259,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -48348,7 +49279,7 @@ var ts; var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); - if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) { + if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } } @@ -48406,18 +49337,18 @@ var ts; } function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) { if (moduleKind >= ts.ModuleKind.ES2015) { - var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import : + var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import : ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; error(name, message, declarationName); } else { if (ts.isInJSFile(node)) { - var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import : + var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import : ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; error(name, message, declarationName); } else { - var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import : + var message = ts.getESModuleInterop(compilerOptions) ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import : ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; error(name, message, declarationName, declarationName, moduleName); } @@ -48484,31 +49415,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 263 /* ImportEqualsDeclaration */: - case 252 /* VariableDeclaration */: + case 264 /* ImportEqualsDeclaration */: + case 253 /* VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 265 /* ImportClause */: + case 266 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 266 /* NamespaceImport */: + case 267 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 272 /* NamespaceExport */: + case 273 /* NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 268 /* ImportSpecifier */: - case 201 /* BindingElement */: + case 269 /* ImportSpecifier */: + case 202 /* BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 273 /* ExportSpecifier */: + case 274 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 269 /* ExportAssignment */: - case 219 /* BinaryExpression */: + case 270 /* ExportAssignment */: + case 220 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 262 /* NamespaceExportDeclaration */: + case 263 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 205 /* ElementAccessExpression */: - case 204 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -48567,13 +49498,13 @@ var ts; * and issue an error if so. * * @param aliasDeclaration The alias declaration not marked as type-only + * @param immediateTarget The symbol to which the alias declaration immediately resolves + * @param finalTarget The symbol to which the alias declaration ultimately resolves + * @param overwriteEmpty Checks `resolvesToSymbol` for type-only declarations even if `aliasDeclaration` * has already been marked as not resolving to a type-only alias. Used when recursively resolving qualified * names of import aliases, e.g. `import C = a.b.C`. If namespace `a` is not found to be type-only, the * import declaration will initially be marked as not resolving to a type-only symbol. But, namespace `b` * must still be checked for a type-only marker, overwriting the previous negative result if found. - * @param immediateTarget The symbol to which the alias declaration immediately resolves - * @param finalTarget The symbol to which the alias declaration ultimately resolves - * @param overwriteEmpty Checks `resolvesToSymbol` for type-only declarations even if `aliasDeclaration` */ function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) { if (!aliasDeclaration || ts.isPropertyAccessExpression(aliasDeclaration)) @@ -48660,19 +49591,41 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 159 /* QualifiedName */) { + if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 160 /* 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 === 263 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 264 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); } + function getContainingQualifiedNameNode(node) { + while (ts.isQualifiedName(node.parent)) { + node = node.parent; + } + return node; + } + function tryGetQualifiedNameAsValue(node) { + var left = ts.getFirstIdentifier(node); + var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + if (!symbol) { + return undefined; + } + while (ts.isQualifiedName(left.parent)) { + var type = getTypeOfSymbol(symbol); + symbol = getPropertyOfType(type, left.parent.right.escapedText); + if (!symbol) { + return undefined; + } + left = left.parent; + } + return symbol; + } /** * Resolves a qualified name and any involved aliases. */ @@ -48685,14 +49638,14 @@ var ts; 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)); + symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); if (!symbol) { return getMergedSymbol(symbolFromJSPrototype); } } - 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; + else if (name.kind === 160 /* QualifiedName */ || name.kind === 205 /* PropertyAccessExpression */) { + var left = name.kind === 160 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 160 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -48719,10 +49672,29 @@ var ts; if (!ignoreErrors) { var namespaceName = getFullyQualifiedName(namespace); var declarationName = ts.declarationNameToString(right); - var suggestion = getSuggestedSymbolForNonexistentModule(right, namespace); - suggestion ? - error(right, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestion)) : - error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName); + var suggestionForNonexistentModule = getSuggestedSymbolForNonexistentModule(right, namespace); + if (suggestionForNonexistentModule) { + error(right, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestionForNonexistentModule)); + return undefined; + } + var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); + var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet + && (meaning & 788968 /* Type */) + && containingQualifiedName + && !ts.isTypeOfExpression(containingQualifiedName.parent) + && tryGetQualifiedNameAsValue(containingQualifiedName); + if (canSuggestTypeof) { + error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); + return undefined; + } + if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (exportedTypeSymbol) { + error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); + return undefined; + } + } + error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName); } return undefined; } @@ -48731,7 +49703,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 === 269 /* ExportAssignment */)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 270 /* ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -48824,6 +49796,7 @@ var ts; : undefined; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { + var _a, _b, _c, _d, _e, _f, _g; if (isForAugmentation === void 0) { isForAugmentation = false; } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; @@ -48835,7 +49808,16 @@ var ts; return ambientModule; } var currentSourceFile = ts.getSourceFileOfNode(location); - var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference); // TODO: GH#18217 + var contextSpecifier = ts.isStringLiteralLike(location) + ? location + : ((_a = ts.findAncestor(location, ts.isImportCall)) === null || _a === void 0 ? void 0 : _a.arguments[0]) || + ((_b = ts.findAncestor(location, ts.isImportDeclaration)) === null || _b === void 0 ? void 0 : _b.moduleSpecifier) || + ((_c = ts.findAncestor(location, ts.isExternalModuleImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.moduleReference.expression) || + ((_d = ts.findAncestor(location, ts.isExportDeclaration)) === null || _d === void 0 ? void 0 : _d.moduleSpecifier) || + ((_e = (ts.isModuleDeclaration(location) ? location : location.parent && ts.isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)) === null || _e === void 0 ? void 0 : _e.name) || + ((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal); + var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat; + var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode); var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { @@ -48843,6 +49825,15 @@ var ts; if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); } + if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { + var isSyncImport = (currentSourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS && !ts.findAncestor(location, ts.isImportCall)) || !!ts.findAncestor(location, ts.isImportEqualsDeclaration); + if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) { + error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); + } + if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) { + error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports); + } + } // merged symbol is module declaration symbol combined with all augmentations return getMergedSymbol(sourceFile.symbol); } @@ -48892,6 +49883,10 @@ var ts; } else { var tsExtension = ts.tryExtractTSExtension(moduleReference); + var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference); + var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); + var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 || + moduleResolutionKind === ts.ModuleResolutionKind.NodeNext; if (tsExtension) { var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; var importSourceWithoutExtension = ts.removeExtension(moduleReference, tsExtension); @@ -48900,18 +49895,30 @@ var ts; * Direct users to import source with .js extension if outputting an ES module. * @see https://github.com/microsoft/TypeScript/issues/42151 */ - var moduleKind_1 = ts.getEmitModuleKind(compilerOptions); - if (moduleKind_1 >= ts.ModuleKind.ES2015) { - replacedImportSource += ".js"; + if (moduleKind >= ts.ModuleKind.ES2015) { + replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && ts.fileExtensionIs(moduleReference, ".json" /* Json */) && - ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs && + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } + else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) { + var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path)); + var suggestedExt = (_g = suggestedExtensions.find(function (_a) { + var actualExt = _a[0], _importExt = _a[1]; + return host.fileExists(absoluteRef_1 + actualExt); + })) === null || _g === void 0 ? void 0 : _g[1]; + if (suggestedExt) { + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt); + } + else { + error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path); + } + } else { error(errorNode, moduleNotFoundError, moduleReference); } @@ -48925,13 +49932,19 @@ var ts; ? typesPackageExists(packageId.name) ? ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_Slash_Slashgithub_com_SlashDefinitelyTyped_SlashDefinitelyTyped_Slashtree_Slashmaster_Slashtypes_Slash_1, packageId.name, ts.mangleScopedPackageName(packageId.name)) - : ts.chainDiagnosticMessages( - /*details*/ undefined, ts.Diagnostics.Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference, ts.mangleScopedPackageName(packageId.name)) + : packageBundlesTypes(packageId.name) + ? ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_declare_module_1, packageId.name, moduleReference) + : ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.Try_npm_i_save_dev_types_Slash_1_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference, ts.mangleScopedPackageName(packageId.name)) : undefined; errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName)); } function typesPackageExists(packageName) { - return getPackagesSet().has(ts.getTypesPackageName(packageName)); + return getPackagesMap().has(ts.getTypesPackageName(packageName)); + } + function packageBundlesTypes(packageName) { + return !!getPackagesMap().get(packageName); } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { @@ -48968,47 +49981,57 @@ 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, 300 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 303 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; error(referencingLocation, ts.Diagnostics.This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export, compilerOptionName); return symbol; } - if (compilerOptions.esModuleInterop) { - var referenceParent = referencingLocation.parent; - if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) || - ts.isImportCall(referenceParent)) { - var type = getTypeOfSymbol(symbol); + var referenceParent = referencingLocation.parent; + if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) || + ts.isImportCall(referenceParent)) { + var reference = ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier; + var type = getTypeOfSymbol(symbol); + var defaultOnlyType = getTypeWithSyntheticDefaultOnly(type, symbol, moduleSymbol, reference); + if (defaultOnlyType) { + return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent); + } + if (ts.getESModuleInterop(compilerOptions)) { var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); if (!sigs || !sigs.length) { sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); } - if (sigs && sigs.length) { - var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol); - // Create a new symbol which has the module's type less the call and construct signatures - var result = createSymbol(symbol.flags, symbol.escapedName); - result.declarations = symbol.declarations ? symbol.declarations.slice() : []; - result.parent = symbol.parent; - result.target = symbol; - result.originatingImport = referenceParent; - if (symbol.valueDeclaration) - result.valueDeclaration = symbol.valueDeclaration; - if (symbol.constEnumOnlyModule) - result.constEnumOnlyModule = true; - if (symbol.members) - result.members = new ts.Map(symbol.members); - 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.indexInfos); - return result; + if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) { + var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); + return cloneTypeAsModuleType(symbol, moduleType, referenceParent); } } } } return symbol; } + /** + * Create a new symbol which has the module's type less the call and construct signatures + */ + function cloneTypeAsModuleType(symbol, moduleType, referenceParent) { + var result = createSymbol(symbol.flags, symbol.escapedName); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; + result.parent = symbol.parent; + result.target = symbol; + result.originatingImport = referenceParent; + if (symbol.valueDeclaration) + result.valueDeclaration = symbol.valueDeclaration; + if (symbol.constEnumOnlyModule) + result.constEnumOnlyModule = true; + if (symbol.members) + result.members = new ts.Map(symbol.members); + 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.indexInfos); + return result; + } function hasExportAssignmentSymbol(moduleSymbol) { return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; } @@ -49037,8 +50060,8 @@ var ts; if (exportEquals !== moduleSymbol) { var type = getTypeOfSymbol(exportEquals); if (shouldTreatPropertiesOfExternalModuleAsExports(type)) { - getPropertiesOfType(type).forEach(function (symbol) { - cb(symbol, symbol.escapedName); + forEachPropertyOfType(type, function (symbol, escapedName) { + cb(symbol, escapedName); }); } } @@ -49312,7 +50335,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 === 169 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 170 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -49370,12 +50393,15 @@ var ts; function getNamedMembers(members) { var result; members.forEach(function (symbol, id) { - if (!isReservedMemberName(id) && symbolIsValue(symbol)) { + if (isNamedMember(symbol, id)) { (result || (result = [])).push(symbol); } }); return result || ts.emptyArray; } + function isNamedMember(member, escapedName) { + return !isReservedMemberName(escapedName) && symbolIsValue(member); + } function getNamedOrIndexSignatureMembers(members) { var result = getNamedMembers(members); var index = getIndexSymbolFromSymbolTable(members); @@ -49419,12 +50445,12 @@ var ts; } } switch (location.kind) { - case 300 /* SourceFile */: + case 303 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 259 /* ModuleDeclaration */: + case 260 /* 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 @@ -49433,9 +50459,9 @@ var ts; return { value: result }; } break; - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: - case 256 /* InterfaceDeclaration */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* 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 @@ -49530,7 +50556,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, 273 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 274 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -49574,7 +50600,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, 273 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 274 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -49589,10 +50615,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 165 /* PropertyDeclaration */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 166 /* PropertyDeclaration */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: continue; default: return false; @@ -49722,10 +50748,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 300 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 303 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 300 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 303 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -49781,14 +50807,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 179 /* TypeQuery */ || + if (entityName.parent.kind === 180 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 160 /* ComputedPropertyName */) { + entityName.parent.kind === 161 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 159 /* QualifiedName */ || entityName.kind === 204 /* PropertyAccessExpression */ || - entityName.parent.kind === 263 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 160 /* QualifiedName */ || entityName.kind === 205 /* PropertyAccessExpression */ || + entityName.parent.kind === 264 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -49829,7 +50855,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) === 300 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 303 /* 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; @@ -49841,10 +50867,10 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 178 /* ConstructorType */ : 177 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 179 /* ConstructorType */ : 178 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 173 /* ConstructSignature */ : 172 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 174 /* ConstructSignature */ : 173 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -49860,7 +50886,9 @@ var ts; var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); - var options = { removeComments: true }; + // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. + // Otherwise, we always strip comments out. + var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); @@ -49940,6 +50968,7 @@ var ts; isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); }, fileExists: function (fileName) { return host.fileExists(fileName); }, getFileIncludeReasons: function () { return host.getFileIncludeReasons(); }, + readFile: host.readFile ? (function (fileName) { return host.readFile(fileName); }) : undefined, } : undefined }, encounteredError: false, reportedDiagnostic: false, @@ -49999,33 +51028,39 @@ var ts; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); } if (!(context.flags & 536870912 /* NoTypeReduction */)) { type = getReducedType(type); } if (type.flags & 1 /* Any */) { + if (type.aliasSymbol) { + return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); + } + if (type === unresolvedType) { + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 137 /* IntrinsicKeyword */ : 129 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(149 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(145 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(146 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(156 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(157 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(132 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -50079,7 +51114,7 @@ var ts; } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(152 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(153 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(150 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; @@ -50087,7 +51122,7 @@ var ts; } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; @@ -50095,15 +51130,15 @@ var ts; } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(142 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(149 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(146 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(147 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -50173,7 +51208,7 @@ var ts; var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(139 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); } if (type.flags & 134217728 /* TemplateLiteral */) { var texts_1 = type.texts; @@ -50233,7 +51268,7 @@ 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(139 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); @@ -50241,7 +51276,7 @@ var ts; var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); - var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode); + var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; return ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); } @@ -50258,7 +51293,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 === 224 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 225 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); @@ -50289,7 +51324,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 300 /* SourceFile */ || declaration.parent.kind === 260 /* ModuleBlock */; + return declaration.parent.kind === 303 /* SourceFile */ || declaration.parent.kind === 261 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -50370,12 +51405,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 177 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 178 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 178 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* ConstructorType */, context); return signatureNode; } } @@ -50418,7 +51453,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(143 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(144 /* 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 */)); }); @@ -50443,12 +51478,12 @@ var ts; } } var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(143 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(144 /* 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(143 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.factory.createTypeOperatorNode(144 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -50555,13 +51590,13 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 172 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 173 /* 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, 173 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; @@ -50598,7 +51633,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -50648,7 +51683,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, 166 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 167 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -50662,12 +51697,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(144 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -50676,8 +51711,8 @@ var ts; } function preserveCommentsOn(node) { var _a; - 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 */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 345 /* JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 345 /* 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 }]); @@ -50778,7 +51813,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.factory.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(143 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.factory.createToken(144 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; @@ -50796,7 +51831,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 === 169 /* 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 === 170 /* 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); @@ -50819,28 +51854,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(129 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 178 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 179 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { var flags = ts.modifiersToFlags(modifiers); modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); } - 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([])) : + var node = kind === 173 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 174 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 167 /* 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 === 168 /* 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 === 170 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 171 /* 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 === 172 /* 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 === 175 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 315 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 178 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 179 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 255 /* 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 === 212 /* 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 === 213 /* 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); @@ -50862,9 +51897,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 162 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 163 /* Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 335 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 338 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -50879,7 +51914,7 @@ var ts; var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? 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 */) : + parameterDeclaration.name.kind === 160 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -51044,11 +52079,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var _a; - var file = ts.getDeclarationOfKind(symbol, 300 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 303 /* SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 300 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 303 /* SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -51093,6 +52128,10 @@ var ts; } return specifier; } + function symbolToEntityNameNode(symbol) { + var identifier = ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(symbol.escapedName)); + return symbol.parent ? ts.factory.createQualifiedName(symbolToEntityNameNode(symbol.parent), identifier) : identifier; + } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module var isTypeOf = meaning === 111551 /* Value */; @@ -51101,7 +52140,7 @@ var ts; var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); var specifier = getSpecifierForModuleSymbol(chain[0], context); - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { // If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error // since declaration files with these kinds of references are liable to fail when published :( context.encounteredError = true; @@ -51324,7 +52363,7 @@ var ts; if (nameType) { if (nameType.flags & 384 /* StringOrNumberLiteral */) { var name = "" + nameType.value; - if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); } if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { @@ -51338,7 +52377,7 @@ var ts; } } function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) { - return ts.isIdentifierText(name, compilerOptions.target) ? ts.factory.createIdentifier(name) : + return ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(name) : !stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) : ts.factory.createStringLiteral(name, !!singleQuote); } @@ -51379,7 +52418,7 @@ var ts; * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` */ function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { - if (type !== errorType && enclosingDeclaration) { + if (!isErrorType(type) && enclosingDeclaration) { var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation @@ -51402,7 +52441,7 @@ var ts; return result; } function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { - if (type !== errorType && context.enclosingDeclaration) { + if (!isErrorType(type) && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); @@ -51455,17 +52494,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 === 314 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 317 /* JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(154 /* 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(151 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -51479,11 +52518,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(129 /* 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(130 /* AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(129 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -51500,16 +52539,16 @@ 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(129 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* 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(129 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -51574,8 +52613,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - 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); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 168 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 167 /* 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 @@ -51639,7 +52678,7 @@ var ts; 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); })), + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, /*alias*/ undefined, id); })), /*moduleSpecifier*/ undefined)], false)))); statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, nsIndex), true), [ns], false), statements.slice(nsIndex + 1), true); } @@ -51694,7 +52733,7 @@ var ts; } function inlineExportModifiers(statements) { // Pass 3: Move all `export {}`'s to `export` modifiers where possible - var index = ts.findIndex(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); }); + var index = ts.findIndex(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !d.assertClause && !!d.exportClause && ts.isNamedExports(d.exportClause); }); if (index >= 0) { var exportDecl = statements[index]; var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { @@ -51718,7 +52757,7 @@ var ts; } else { // some items filtered, others not - update the export declaration - statements[index] = ts.factory.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.isTypeOnly, ts.factory.updateNamedExports(exportDecl.exportClause, replacements), exportDecl.moduleSpecifier); + statements[index] = ts.factory.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.isTypeOnly, ts.factory.updateNamedExports(exportDecl.exportClause, replacements), exportDecl.moduleSpecifier, exportDecl.assertClause); } } return statements; @@ -51867,7 +52906,7 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(alias, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); } else { @@ -51900,7 +52939,7 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -51958,7 +52997,7 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); } } function includePrivateSymbol(symbol) { @@ -52035,8 +53074,8 @@ 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, 172 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 173 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 173 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 174 /* ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); 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( @@ -52080,7 +53119,7 @@ var ts; var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); includePrivateSymbol(target || s); var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName; - return ts.factory.createExportSpecifier(name === targetName ? undefined : targetName, name); + return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name === targetName ? undefined : targetName, name); })))]); addResult(ts.factory.createModuleDeclaration( /*decorators*/ undefined, @@ -52105,7 +53144,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, 254 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 255 /* 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 @@ -52171,7 +53210,7 @@ var ts; var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported @@ -52265,13 +53304,34 @@ 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, 169 /* Constructor */); + serializeSignatures(1 /* Construct */, staticType, staticBaseType, 170 /* 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, 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 getSomeTargetNameFromDeclarations(declarations) { + return ts.firstDefined(declarations, function (d) { + if (ts.isImportSpecifier(d) || ts.isExportSpecifier(d)) { + return ts.idText(d.propertyName || d.name); + } + if (ts.isBinaryExpression(d) || ts.isExportAssignment(d)) { + var expression = ts.isExportAssignment(d) ? d.expression : d.right; + if (ts.isPropertyAccessExpression(expression)) { + return ts.idText(expression.name); + } + } + if (isAliasSymbolDeclaration(d)) { + // This is... heuristic, at best. But it's probably better than always printing the name of the shorthand ambient module. + var name = ts.getNameOfDeclaration(d); + if (name && ts.isIdentifier(name)) { + return ts.idText(name); + } + } + return undefined; + }); + } function serializeAsAlias(symbol, localName, modifierFlags) { var _a, _b, _c, _d, _e; // synthesize an alias, eg `export { symbolName as Name }` @@ -52284,34 +53344,38 @@ var ts; if (!target) { return; } - var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol + // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that + var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match verbatimTargetName = "default" /* Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - 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 */) { + case 202 /* BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 253 /* VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier(propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1)), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( + /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), + /*importClause*/ undefined), 0 /* None */); break; } // 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 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 */) { + case 295 /* ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 220 /* BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -52331,7 +53395,7 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 263 /* ImportEqualsDeclaration */: + case 264 /* 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)) { @@ -52348,42 +53412,46 @@ var ts; ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); break; - case 262 /* NamespaceExportDeclaration */: + case 263 /* 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 265 /* ImportClause */: + case 266 /* ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already - ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), + /*assertClause*/ undefined), 0 /* None */); break; - case 266 /* NamespaceImport */: + case 267 /* 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 */); + /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), + /*assertClause*/ undefined), 0 /* None */); break; - case 272 /* NamespaceExport */: + case 273 /* 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 268 /* ImportSpecifier */: + case 269 /* ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( /*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamedImports([ - ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) - ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + ts.factory.createImportSpecifier( + /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) + ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), + /*assertClause*/ undefined), 0 /* None */); break; - case 273 /* ExportSpecifier */: + case 274 /* 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; @@ -52391,12 +53459,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 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 219 /* BinaryExpression */: - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 220 /* BinaryExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* 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 @@ -52415,7 +53483,7 @@ var ts; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol @@ -52809,7 +53877,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 === 257 /* TypeAliasDeclaration */) { + if (node.kind === 258 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -52817,18 +53885,18 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 260 /* ModuleBlock */ && + node.parent.kind === 261 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 300 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 303 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { if (nameType.flags & 384 /* StringOrNumberLiteral */) { var name = "" + nameType.value; - if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) { return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; } if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { @@ -52880,17 +53948,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 252 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 253 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 224 /* ClassExpression */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 225 /* ClassExpression */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 224 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 225 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -52907,28 +53975,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 333 /* JSDocCallbackTag */: - case 340 /* JSDocTypedefTag */: - case 334 /* JSDocEnumTag */: + case 336 /* JSDocCallbackTag */: + case 343 /* JSDocTypedefTag */: + case 337 /* 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 201 /* BindingElement */: + case 202 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 252 /* VariableDeclaration */: + case 253 /* 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 259 /* ModuleDeclaration */: - case 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 254 /* FunctionDeclaration */: - case 258 /* EnumDeclaration */: - case 263 /* ImportEqualsDeclaration */: + case 260 /* ModuleDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 255 /* FunctionDeclaration */: + case 259 /* EnumDeclaration */: + case 264 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -52936,55 +54004,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 !== 263 /* ImportEqualsDeclaration */ && parent.kind !== 300 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { + !(node.kind !== 264 /* ImportEqualsDeclaration */ && parent.kind !== 303 /* 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 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 167 /* 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 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 */: + case 170 /* Constructor */: + case 174 /* ConstructSignature */: + case 173 /* CallSignature */: + case 175 /* IndexSignature */: + case 163 /* Parameter */: + case 261 /* ModuleBlock */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: + case 181 /* TypeLiteral */: + case 177 /* TypeReference */: + case 182 /* ArrayType */: + case 183 /* TupleType */: + case 186 /* UnionType */: + case 187 /* IntersectionType */: + case 190 /* ParenthesizedType */: + case 196 /* 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 265 /* ImportClause */: - case 266 /* NamespaceImport */: - case 268 /* ImportSpecifier */: + case 266 /* ImportClause */: + case 267 /* NamespaceImport */: + case 269 /* ImportSpecifier */: return false; // Type parameters are always visible - case 161 /* TypeParameter */: + case 162 /* TypeParameter */: // Source file and namespace export are always visible // falls through - case 300 /* SourceFile */: - case 262 /* NamespaceExportDeclaration */: + case 303 /* SourceFile */: + case 263 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: return false; default: return false; @@ -52993,10 +54061,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 269 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 270 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 273 /* ExportSpecifier */) { + else if (node.parent.kind === 274 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -53101,12 +54169,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 252 /* VariableDeclaration */: - case 253 /* VariableDeclarationList */: - case 268 /* ImportSpecifier */: - case 267 /* NamedImports */: - case 266 /* NamespaceImport */: - case 265 /* ImportClause */: + case 253 /* VariableDeclaration */: + case 254 /* VariableDeclarationList */: + case 269 /* ImportSpecifier */: + case 268 /* NamedImports */: + case 267 /* NamespaceImport */: + case 266 /* ImportClause */: return false; default: return true; @@ -53133,6 +54201,11 @@ var ts; function isTypeAny(type) { return type && (type.flags & 1 /* Any */) !== 0; } + function isErrorType(type) { + // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for + // a reference to an unresolved symbol. We want those to behave like the errorType. + return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node) { @@ -53212,23 +54285,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 201 /* BindingElement */: - case 291 /* PropertyAssignment */: + case 202 /* BindingElement */: + case 294 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return ancestor.initializer; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 201 /* BindingElement */ && parent.kind === 199 /* ObjectBindingPattern */) { + if (node.kind === 202 /* BindingElement */ && parent.kind === 200 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 291 /* PropertyAssignment */ || node.kind === 292 /* ShorthandPropertyAssignment */) { + if (node.kind === 294 /* PropertyAssignment */ || node.kind === 295 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -53254,7 +54327,7 @@ var ts; parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); } var type; - if (pattern.kind === 199 /* ObjectBindingPattern */) { + if (pattern.kind === 200 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { @@ -53320,12 +54393,12 @@ var ts; return undefined; } function isNullOrUndefined(node) { - var expr = ts.skipParentheses(node); + var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { - var expr = ts.skipParentheses(node); - return expr.kind === 202 /* ArrayLiteralExpression */ && expr.elements.length === 0; + var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); + return expr.kind === 203 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -53336,11 +54409,11 @@ var ts; 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 === 241 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* 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 === 242 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* 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, @@ -53378,8 +54451,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 === 171 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 170 /* GetAccessor */); + if (func.kind === 172 /* SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 171 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -53459,7 +54532,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 205 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 206 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -53481,7 +54554,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 === 169 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 170 /* Constructor */ || isJSConstructor(container))) { return container; } } @@ -53650,7 +54723,7 @@ var ts; if (!declaredType) { return type; } - else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) { + else if (!isErrorType(declaredType) && !isErrorType(type) && !isTypeIdenticalTo(declaredType, type)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type); } } @@ -53764,9 +54837,9 @@ var ts; 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 === 169 /* Constructor */ || - thisContainer.kind === 254 /* FunctionDeclaration */ || - (thisContainer.kind === 211 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 170 /* Constructor */ || + thisContainer.kind === 255 /* FunctionDeclaration */ || + (thisContainer.kind === 212 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -53836,7 +54909,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 201 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 202 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -53861,7 +54934,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 199 /* ObjectBindingPattern */ + return pattern.kind === 200 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -53909,7 +54982,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 162 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 163 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -53984,8 +55057,8 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 269 /* ExportAssignment */) { - type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); + if (declaration.kind === 270 /* ExportAssignment */) { + type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || (ts.isInJSFile(declaration) && @@ -54055,7 +55128,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 170 /* GetAccessor */) { + if (accessor.kind === 171 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -54094,7 +55167,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 170 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 171 /* 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)); } } @@ -54102,8 +55175,8 @@ var ts; } function resolveTypeOfAccessors(symbol, writing) { if (writing === void 0) { writing = false; } - var getter = ts.getDeclarationOfKind(symbol, 170 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 171 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); // For write operations, prioritize type annotations on the setter if (writing && setterType) { @@ -54180,9 +55253,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 219 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 220 /* BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 219 /* BinaryExpression */)) { + declaration.parent.kind === 220 /* BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -54217,6 +55290,7 @@ var ts; if (!links.type) { var targetSymbol = resolveAlias(symbol); var exportSymbol = symbol.declarations && getTargetOfAliasDeclaration(getDeclarationOfAliasSymbol(symbol), /*dontResolveAlias*/ true); + var declaredType = ts.firstDefined(exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations, function (d) { return ts.isExportAssignment(d) ? tryGetTypeFromEffectiveTypeNode(d) : undefined; }); // It only makes sense to get the type of a value symbol. If the result of resolving // the alias is not a value, then it has no type. To get the type associated with a // type symbol, call getDeclaredTypeOfSymbol. @@ -54224,8 +55298,9 @@ var ts; // up recursively calling getTypeOfAlias, causing a stack overflow. links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) - : errorType; + : declaredType ? declaredType + : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : errorType; } return links.type; } @@ -54251,7 +55326,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 162 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 163 /* 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 @@ -54362,46 +55437,46 @@ var ts; return undefined; } switch (node.kind) { - 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 */: { + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 167 /* MethodSignature */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: + case 315 /* JSDocFunctionType */: + case 255 /* FunctionDeclaration */: + case 168 /* MethodDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 258 /* TypeAliasDeclaration */: + case 342 /* JSDocTemplateTag */: + case 343 /* JSDocTypedefTag */: + case 337 /* JSDocEnumTag */: + case 336 /* JSDocCallbackTag */: + case 194 /* MappedType */: + case 188 /* ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 193 /* MappedType */) { + if (node.kind === 194 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 187 /* ConditionalType */) { + else if (node.kind === 188 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 255 /* ClassDeclaration */ || node.kind === 224 /* ClassExpression */ || node.kind === 256 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 256 /* ClassDeclaration */ || node.kind === 225 /* ClassExpression */ || node.kind === 257 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 335 /* JSDocParameterTag */: + case 338 /* JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 315 /* JSDocComment */: { + case 318 /* JSDocComment */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -54412,7 +55487,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, 256 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 257 /* InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -54425,9 +55500,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 256 /* InterfaceDeclaration */ || - node.kind === 255 /* ClassDeclaration */ || - node.kind === 224 /* ClassExpression */ || + if (node.kind === 257 /* InterfaceDeclaration */ || + node.kind === 256 /* ClassDeclaration */ || + node.kind === 225 /* ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -54542,7 +55617,7 @@ var ts; for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { var node = implementsTypeNodes_1[_b]; var implementsType = getTypeFromTypeNode(node); - if (implementsType !== errorType) { + if (!isErrorType(implementsType)) { if (resolvedImplementsTypes === ts.emptyArray) { resolvedImplementsTypes = [implementsType]; } @@ -54578,7 +55653,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 === 255 /* ClassDeclaration */ || declaration.kind === 256 /* InterfaceDeclaration */) { + if (declaration.kind === 256 /* ClassDeclaration */ || declaration.kind === 257 /* InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -54622,7 +55697,7 @@ var ts; } baseType = getReturnTypeOfSignature(constructors[0]); } - if (baseType === errorType) { + if (isErrorType(baseType)) { return type.resolvedBaseTypes = ts.emptyArray; } var reducedBaseType = getReducedType(baseType); @@ -54674,11 +55749,11 @@ 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 === 256 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 257 /* 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)); - if (baseType !== errorType) { + if (!isErrorType(baseType)) { if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === ts.emptyArray) { @@ -54714,7 +55789,7 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 256 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* InterfaceDeclaration */) { if (declaration.flags & 128 /* ContainsThis */) { return false; } @@ -54793,7 +55868,7 @@ var ts; } else { type = errorType; - if (declaration.kind === 334 /* JSDocEnumTag */) { + if (declaration.kind === 337 /* JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { @@ -54808,7 +55883,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 219 /* BinaryExpression */) { + else if (expr.kind === 220 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -54823,12 +55898,12 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 79 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -54843,7 +55918,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* EnumDeclaration */) { + if (declaration.kind === 259 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { @@ -54872,7 +55947,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* EnumDeclaration */) { + if (declaration.kind === 259 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -54945,22 +56020,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - 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 130 /* AnyKeyword */: + case 154 /* UnknownKeyword */: + case 149 /* StringKeyword */: + case 146 /* NumberKeyword */: + case 157 /* BigIntKeyword */: + case 133 /* BooleanKeyword */: + case 150 /* SymbolKeyword */: + case 147 /* ObjectKeyword */: case 114 /* VoidKeyword */: - case 151 /* UndefinedKeyword */: - case 142 /* NeverKeyword */: - case 194 /* LiteralType */: + case 152 /* UndefinedKeyword */: + case 143 /* NeverKeyword */: + case 195 /* LiteralType */: return true; - case 181 /* ArrayType */: + case 182 /* ArrayType */: return isThislessType(node.elementType); - case 176 /* TypeReference */: + case 177 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -54986,7 +56061,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 169 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 170 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -55002,14 +56077,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: - case 169 /* Constructor */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -55903,6 +56978,23 @@ var ts; function getIsLateCheckFlag(s) { return ts.getCheckFlags(s) & 4096 /* Late */; } + function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { + for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + cb(getLiteralTypeFromProperty(prop, include)); + } + if (type.flags & 1 /* Any */) { + cb(stringType); + } + else { + for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { + var info = _c[_b]; + if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + cb(info.keyType); + } + } + } + } /** Resolve the members of a mapped type { [P in K]: T } */ function resolveMappedTypeMembers(type) { var members = ts.createSymbolTable(); @@ -55920,21 +57012,7 @@ var ts; var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } - for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { - var prop = _a[_i]; - addMemberForKeyType(getLiteralTypeFromProperty(prop, include)); - } - if (modifiersType.flags & 1 /* Any */) { - addMemberForKeyType(stringType); - } - 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); - } - } - } + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); } else { forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType); @@ -56036,8 +57114,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 191 /* TypeOperator */ && - constraintDeclaration.operator === 139 /* KeyOfKeyword */; + return constraintDeclaration.kind === 192 /* TypeOperator */ && + constraintDeclaration.operator === 140 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -56156,6 +57234,16 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } + function forEachPropertyOfType(type, action) { + type = getReducedApparentType(type); + if (type.flags & 3670016 /* StructuredType */) { + resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { + if (isNamedMember(symbol, escapedName)) { + action(symbol, escapedName); + } + }); + } + } function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) { var list = obj.properties; return list.some(function (property) { @@ -56515,12 +57603,12 @@ var ts; // Flags we want to propagate to the result if they exist in all source symbols var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = 0; + var checkFlags = isUnion ? 0 : 8 /* Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(type === errorType || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { @@ -56555,8 +57643,13 @@ var ts; } } } - checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | - (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | + if (isUnion && isReadonlySymbol(prop)) { + checkFlags |= 8 /* Readonly */; + } + else if (!isUnion && !isReadonlySymbol(prop)) { + checkFlags &= ~8 /* Readonly */; + } + checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); @@ -56624,7 +57717,7 @@ var ts; else if (type !== firstType) { checkFlags |= 64 /* HasNonUniformType */; } - if (isLiteralType(type)) { + if (isLiteralType(type) || isPatternLiteralType(type)) { checkFlags |= 128 /* HasLiteralType */; } if (type.flags & 131072 /* Never */) { @@ -56873,10 +57966,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 === 311 /* JSDocOptionalType */ + node.type && node.type.kind === 314 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 311 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 314 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -56916,7 +58009,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 311 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 314 /* JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -56998,7 +58091,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 194 /* LiteralType */) { + if (type && type.kind === 195 /* LiteralType */) { flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter @@ -57011,16 +58104,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 === 170 /* GetAccessor */ || declaration.kind === 171 /* SetAccessor */) && + if ((declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 170 /* GetAccessor */ ? 171 /* SetAccessor */ : 170 /* GetAccessor */; + var otherKind = declaration.kind === 171 /* GetAccessor */ ? 172 /* SetAccessor */ : 171 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 169 /* Constructor */ ? + var classType = declaration.kind === 170 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -57087,15 +58180,15 @@ var ts; return false; switch (node.kind) { case 79 /* Identifier */: - return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol; - case 165 /* PropertyDeclaration */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - return node.name.kind === 160 /* ComputedPropertyName */ + return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; + case 166 /* PropertyDeclaration */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + return node.name.kind === 161 /* ComputedPropertyName */ && traverse(node.name); - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: return traverse(node.expression); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -57167,7 +58260,7 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 190 /* ThisType */ ? + return parameterName.kind === 191 /* 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); } @@ -57213,7 +58306,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 169 /* Constructor */) { + if (declaration.kind === 170 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -57223,12 +58316,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 170 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 171 /* GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 171 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 172 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -57329,7 +58422,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 169 /* Constructor */ || kind === 173 /* ConstructSignature */ || kind === 178 /* ConstructorType */; + var isConstructor = kind === 170 /* Constructor */ || kind === 174 /* ConstructSignature */ || kind === 179 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -57378,7 +58471,7 @@ var ts; } 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); + !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -57389,13 +58482,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 === 188 /* InferType */) { + if (declaration.parent.kind === 189 /* 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 === 176 /* TypeReference */) { + if (grandParent.kind === 177 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -57420,27 +58513,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 === 162 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 184 /* RestType */ || - grandParent.kind === 195 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 163 /* Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 185 /* RestType */ || + grandParent.kind === 196 /* 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 === 197 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 198 /* 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 === 161 /* TypeParameter */ && grandParent.parent.kind === 193 /* MappedType */) { + else if (grandParent.kind === 162 /* TypeParameter */ && grandParent.parent.kind === 194 /* 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 === 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 */ && + else if (grandParent.kind === 194 /* MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 188 /* ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 194 /* MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); @@ -57465,10 +58558,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && type !== errorType) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* Any */ && !isErrorType(type)) { // 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 === 193 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 194 /* MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -57477,8 +58570,8 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 161 /* TypeParameter */); - var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 162 /* TypeParameter */); + var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } function getTypeListId(types) { @@ -57563,8 +58656,8 @@ var ts; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 176 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 181 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 177 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 182 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -57606,7 +58699,7 @@ var ts; return errorType; } } - if (node.kind === 176 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 177 /* 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 @@ -57637,6 +58730,18 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { + if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + var typeArguments = typeArgumentsFromTypeReferenceNode(node); + var id = getAliasId(symbol, typeArguments); + var errorType_1 = errorTypes.get(id); + if (!errorType_1) { + errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1.aliasSymbol = symbol; + errorType_1.aliasTypeArguments = typeArguments; + errorTypes.set(id, errorType_1); + } + return errorType_1; + } var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { @@ -57665,9 +58770,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 176 /* TypeReference */: + case 177 /* TypeReference */: return node.typeName; - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -57678,11 +58783,37 @@ var ts; } return undefined; } - function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) { - if (!typeReferenceName) { + function getSymbolPath(symbol) { + return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + } + function getUnresolvedSymbolForEntityName(name) { + var identifier = name.kind === 160 /* QualifiedName */ ? name.right : + name.kind === 205 /* PropertyAccessExpression */ ? name.name : + name; + var text = identifier.escapedText; + if (text) { + var parentSymbol = name.kind === 160 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 205 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + undefined; + var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var result = unresolvedSymbols.get(path); + if (!result) { + unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + result.parent = parentSymbol; + result.declaredType = unresolvedType; + } + return result; + } + return unknownSymbol; + } + function resolveTypeReferenceName(typeReference, meaning, ignoreErrors) { + var name = getTypeReferenceName(typeReference); + if (!name) { return unknownSymbol; } - return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; + var symbol = resolveEntityName(name, meaning, ignoreErrors); + return symbol && symbol !== unknownSymbol ? symbol : + ignoreErrors ? unknownSymbol : getUnresolvedSymbolForEntityName(name); } function getTypeReferenceType(node, symbol) { if (symbol === unknownSymbol) { @@ -57707,7 +58838,7 @@ var ts; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* Type */); return getTypeOfSymbol(symbol); } } @@ -57723,7 +58854,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 198 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 199 /* 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); @@ -57749,7 +58880,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 182 /* TupleType */ && node.elements.length === 1; + return node.kind === 183 /* TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -57759,16 +58890,16 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 315 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 318 /* 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 === 162 /* Parameter */) { + if (parent.kind === 163 /* 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 === 187 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 188 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -57779,7 +58910,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 176 /* TypeReference */ || node.kind === 198 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 177 /* TypeReference */ || node.kind === 199 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -57851,18 +58982,18 @@ var ts; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { - symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, /*ignoreErrors*/ true); + symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); } else { - resolveTypeReferenceName(getTypeReferenceName(node), meaning); // Resolve again to mark errors, if any + resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any } type = getTypeReferenceType(node, symbol); } } if (!type) { - symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning); + symbol = resolveTypeReferenceName(node, meaning); type = getTypeReferenceType(node, symbol); } // Cache both the resolved symbol and the resolved type. The resolved symbol is needed when we check the @@ -57894,9 +59025,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: - case 258 /* EnumDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 259 /* EnumDeclaration */: return declaration; } } @@ -57922,6 +59053,20 @@ var ts; function getGlobalTypeSymbol(name, reportErrors) { return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } + function getGlobalTypeAliasSymbol(name, arity, reportErrors) { + var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + if (symbol) { + // Resolve the declared type of the symbol. This resolves type parameters for the type + // alias so that we can check arity. + getDeclaredTypeOfSymbol(symbol); + if (ts.length(getSymbolLinks(symbol).typeParameters) !== arity) { + var decl = symbol.declarations && ts.find(symbol.declarations, ts.isTypeAliasDeclaration); + error(decl, ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, ts.symbolName(symbol), arity); + return undefined; + } + } + return symbol; + } function getGlobalSymbol(name, meaning, diagnostic) { // Don't track references for global symbols anyway, so value if `isReference` is arbitrary return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false); @@ -57931,13 +59076,16 @@ var ts; return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined; } function getGlobalTypedPropertyDescriptorType() { - return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", /*arity*/ 1, /*reportErrors*/ true)) || emptyGenericType; + // We always report an error, so store a result in the event we could not resolve the symbol to prevent reporting it multiple times + return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", /*arity*/ 1, /*reportErrors*/ true) || emptyGenericType); } function getGlobalTemplateStringsArrayType() { - return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", /*arity*/ 0, /*reportErrors*/ true)) || emptyObjectType; + // We always report an error, so store a result in the event we could not resolve the symbol to prevent reporting it multiple times + return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", /*arity*/ 0, /*reportErrors*/ true) || emptyObjectType); } function getGlobalImportMetaType() { - return deferredGlobalImportMetaType || (deferredGlobalImportMetaType = getGlobalType("ImportMeta", /*arity*/ 0, /*reportErrors*/ true)) || emptyObjectType; + // We always report an error, so store a result in the event we could not resolve the symbol to prevent reporting it multiple times + return deferredGlobalImportMetaType || (deferredGlobalImportMetaType = getGlobalType("ImportMeta", /*arity*/ 0, /*reportErrors*/ true) || emptyObjectType); } function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { @@ -57953,6 +59101,9 @@ var ts; } return deferredGlobalImportMetaExpressionType; } + function getGlobalImportCallOptionsType(reportErrors) { + return (deferredGlobalImportCallOptionsType || (deferredGlobalImportCallOptionsType = getGlobalType("ImportCallOptions", /*arity*/ 0, reportErrors))) || emptyObjectType; + } function getGlobalESSymbolConstructorSymbol(reportErrors) { return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); } @@ -57960,49 +59111,49 @@ var ts; return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors)); } function getGlobalESSymbolType(reportErrors) { - return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors)) || emptyObjectType; + return (deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors))) || emptyObjectType; } function getGlobalPromiseType(reportErrors) { - return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors)) || emptyGenericType; + return (deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors))) || emptyGenericType; } function getGlobalPromiseLikeType(reportErrors) { - return deferredGlobalPromiseLikeType || (deferredGlobalPromiseLikeType = getGlobalType("PromiseLike", /*arity*/ 1, reportErrors)) || emptyGenericType; + return (deferredGlobalPromiseLikeType || (deferredGlobalPromiseLikeType = getGlobalType("PromiseLike", /*arity*/ 1, reportErrors))) || emptyGenericType; } function getGlobalPromiseConstructorSymbol(reportErrors) { return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors)); } function getGlobalPromiseConstructorLikeType(reportErrors) { - return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", /*arity*/ 0, reportErrors)) || emptyObjectType; + return (deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", /*arity*/ 0, reportErrors))) || emptyObjectType; } function getGlobalAsyncIterableType(reportErrors) { - return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", /*arity*/ 1, reportErrors)) || emptyGenericType; + return (deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", /*arity*/ 1, reportErrors))) || emptyGenericType; } function getGlobalAsyncIteratorType(reportErrors) { - return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", /*arity*/ 3, reportErrors)) || emptyGenericType; + return (deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", /*arity*/ 3, reportErrors))) || emptyGenericType; } function getGlobalAsyncIterableIteratorType(reportErrors) { - return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + return (deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", /*arity*/ 1, reportErrors))) || emptyGenericType; } function getGlobalAsyncGeneratorType(reportErrors) { - return deferredGlobalAsyncGeneratorType || (deferredGlobalAsyncGeneratorType = getGlobalType("AsyncGenerator", /*arity*/ 3, reportErrors)) || emptyGenericType; + return (deferredGlobalAsyncGeneratorType || (deferredGlobalAsyncGeneratorType = getGlobalType("AsyncGenerator", /*arity*/ 3, reportErrors))) || emptyGenericType; } function getGlobalIterableType(reportErrors) { - return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", /*arity*/ 1, reportErrors)) || emptyGenericType; + return (deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", /*arity*/ 1, reportErrors))) || emptyGenericType; } function getGlobalIteratorType(reportErrors) { - return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", /*arity*/ 3, reportErrors)) || emptyGenericType; + return (deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", /*arity*/ 3, reportErrors))) || emptyGenericType; } function getGlobalIterableIteratorType(reportErrors) { - return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + return (deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1, reportErrors))) || emptyGenericType; } function getGlobalGeneratorType(reportErrors) { - return deferredGlobalGeneratorType || (deferredGlobalGeneratorType = getGlobalType("Generator", /*arity*/ 3, reportErrors)) || emptyGenericType; + return (deferredGlobalGeneratorType || (deferredGlobalGeneratorType = getGlobalType("Generator", /*arity*/ 3, reportErrors))) || emptyGenericType; } function getGlobalIteratorYieldResultType(reportErrors) { - return deferredGlobalIteratorYieldResultType || (deferredGlobalIteratorYieldResultType = getGlobalType("IteratorYieldResult", /*arity*/ 1, reportErrors)) || emptyGenericType; + return (deferredGlobalIteratorYieldResultType || (deferredGlobalIteratorYieldResultType = getGlobalType("IteratorYieldResult", /*arity*/ 1, reportErrors))) || emptyGenericType; } function getGlobalIteratorReturnResultType(reportErrors) { - return deferredGlobalIteratorReturnResultType || (deferredGlobalIteratorReturnResultType = getGlobalType("IteratorReturnResult", /*arity*/ 1, reportErrors)) || emptyGenericType; + return (deferredGlobalIteratorReturnResultType || (deferredGlobalIteratorReturnResultType = getGlobalType("IteratorReturnResult", /*arity*/ 1, reportErrors))) || emptyGenericType; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } @@ -58010,13 +59161,22 @@ var ts; return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { - return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + // We always report an error, so cache a result in the event we could not resolve the symbol to prevent reporting it multiple times + deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalTypeAliasSymbol("Extract", /*arity*/ 2, /*reportErrors*/ true) || unknownSymbol); + return deferredGlobalExtractSymbol === unknownSymbol ? undefined : deferredGlobalExtractSymbol; } function getGlobalOmitSymbol() { - return deferredGlobalOmitSymbol || (deferredGlobalOmitSymbol = getGlobalSymbol("Omit", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 + // We always report an error, so cache a result in the event we could not resolve the symbol to prevent reporting it multiple times + deferredGlobalOmitSymbol || (deferredGlobalOmitSymbol = getGlobalTypeAliasSymbol("Omit", /*arity*/ 2, /*reportErrors*/ true) || unknownSymbol); + return deferredGlobalOmitSymbol === unknownSymbol ? undefined : deferredGlobalOmitSymbol; + } + function getGlobalAwaitedSymbol(reportErrors) { + // Only cache `unknownSymbol` if we are reporting errors so that we don't report the error more than once. + deferredGlobalAwaitedSymbol || (deferredGlobalAwaitedSymbol = getGlobalTypeAliasSymbol("Awaited", /*arity*/ 1, reportErrors) || (reportErrors ? unknownSymbol : undefined)); + return deferredGlobalAwaitedSymbol === unknownSymbol ? undefined : deferredGlobalAwaitedSymbol; } function getGlobalBigIntType(reportErrors) { - return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors)) || emptyObjectType; + return (deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", /*arity*/ 0, reportErrors))) || emptyObjectType; } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. @@ -58035,11 +59195,11 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 183 /* OptionalType */: + case 184 /* OptionalType */: return 2 /* Optional */; - case 184 /* RestType */: + case 185 /* RestType */: return getRestTypeElementFlags(node); - case 195 /* NamedTupleMember */: + case 196 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; @@ -58057,14 +59217,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 !== 195 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 196 /* 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 === 181 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 182 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 182 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 183 /* 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 @@ -58073,18 +59233,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - 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 */: + case 190 /* ParenthesizedType */: + case 196 /* NamedTupleMember */: + case 177 /* TypeReference */: + case 186 /* UnionType */: + case 187 /* IntersectionType */: + case 193 /* IndexedAccessType */: + case 188 /* ConditionalType */: + case 192 /* TypeOperator */: + case 182 /* ArrayType */: + case 183 /* TupleType */: return isResolvedByTypeAlias(parent); - case 257 /* TypeAliasDeclaration */: + case 258 /* TypeAliasDeclaration */: return true; } return false; @@ -58093,28 +59253,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 176 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 179 /* TypeQuery */: + case 177 /* TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); + case 180 /* TypeQuery */: return true; - 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 */: + case 192 /* TypeOperator */: + return node.operator !== 153 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 190 /* ParenthesizedType */: + case 184 /* OptionalType */: + case 196 /* NamedTupleMember */: + case 314 /* JSDocOptionalType */: + case 312 /* JSDocNullableType */: + case 313 /* JSDocNonNullableType */: + case 307 /* JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 184 /* RestType */: - return node.type.kind !== 181 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 185 /* UnionType */: - case 186 /* IntersectionType */: + case 185 /* RestType */: + return node.type.kind !== 182 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 186 /* UnionType */: + case 187 /* IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 192 /* IndexedAccessType */: + case 193 /* IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 187 /* ConditionalType */: + case 188 /* ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -58127,19 +59287,19 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - 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 : + else if (!(node.kind === 183 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 183 /* TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 181 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 182 /* 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 === 143 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 144 /* ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } @@ -58369,8 +59529,8 @@ var ts; // We ignore 'never' types in unions if (!(flags & 131072 /* Never */)) { includes |= flags & 205258751 /* IncludesMask */; - if (flags & 469499904 /* StructuredOrInstantiable */) - includes |= 262144 /* IncludesStructuredOrInstantiable */; + if (flags & 465829888 /* Instantiable */) + includes |= 33554432 /* IncludesInstantiable */; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { @@ -58479,7 +59639,7 @@ var ts; var _loop_16 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeSubtypeOf(t, template); })) { + if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; @@ -58529,7 +59689,9 @@ var ts; var includes = addTypesToUnion(typeSet, 0, types); if (unionReduction !== 0 /* None */) { if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType; + return includes & 1 /* Any */ ? + includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); @@ -58582,7 +59744,7 @@ var ts; origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); } } - var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) | + var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) | (includes & 2097152 /* Intersection */ ? 33554432 /* ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } @@ -58674,13 +59836,19 @@ var ts; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; } - else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { - // We have seen two distinct unit types which means we should reduce to an - // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + if (exactOptionalPropertyTypes && type === missingType) { + includes |= 262144 /* IncludesMissingType */; + type = undefinedType; + } + if (!typeSet.has(type.id.toString())) { + if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + // We have seen two distinct unit types which means we should reduce to an + // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. + includes |= 67108864 /* NonPrimitive */; + } + typeSet.set(type.id.toString(), type); } - typeSet.set(type.id.toString(), type); } includes |= flags & 205258751 /* IncludesMask */; } @@ -58753,14 +59921,13 @@ var ts; } return false; } - function extractIrreducible(types, flag) { - if (ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) { - for (var i = 0; i < types.length; i++) { - types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); - } - return true; + function eachIsUnionContaining(types, flag) { + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + } + function removeFromEach(types, flag) { + for (var i = 0; i < types.length; i++) { + types[i] = filterType(types[i], function (t) { return !(t.flags & flag); }); } - return false; } // If the given list of types contains more than one union of primitive types, replace the // first with a union containing an intersection of those primitive types, then remove the @@ -58869,6 +60036,9 @@ var ts; if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) { ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } + if (includes & 262144 /* IncludesMissingType */) { + typeSet[typeSet.indexOf(undefinedType)] = missingType; + } if (typeSet.length === 0) { return unknownType; } @@ -58885,10 +60055,13 @@ var ts; // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (extractIrreducible(typeSet, 32768 /* Undefined */)) { - result = getUnionType([getIntersectionType(typeSet), undefinedType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; + removeFromEach(typeSet, 32768 /* Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); } - else if (extractIrreducible(typeSet, 65536 /* Null */)) { + else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { + removeFromEach(typeSet, 65536 /* Null */); result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); } else { @@ -58968,18 +60141,56 @@ var ts; type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, /*stringsOnly*/ true)) : type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, /*stringsOnly*/ false)); } - function instantiateTypeAsMappedNameType(nameType, type, t) { - return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t)); - } - function getIndexTypeForMappedType(type, noIndexSignatures) { - var constraint = filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 /* Any */ | 4 /* String */)); }); - var nameType = type.declaration.nameType && getTypeFromTypeNode(type.declaration.nameType); - // If the constraint is exclusively string/number/never type(s), we need to pull the property names from the modified type and run them through the `nameType` mapper as well - // since they won't appear in the constraint, due to subtype reducing with the string/number index types - var properties = nameType && everyType(constraint, function (t) { return !!(t.flags & (4 /* String */ | 8 /* Number */ | 131072 /* Never */)); }) && getPropertiesOfType(getApparentType(getModifiersTypeFromMappedType(type))); - return nameType ? - getUnionType([mapType(constraint, function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); }), mapType(getUnionType(ts.map(properties || ts.emptyArray, function (p) { return getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */); })), function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); })]) : - constraint; + /** + * This roughly mirrors `resolveMappedTypeMembers` in the nongeneric case, except only reports a union of the keys calculated, + * rather than manufacturing the properties. We can't just fetch the `constraintType` since that would ignore mappings + * and mapping the `constraintType` directly ignores how mapped types map _properties_ and not keys (thus ignoring subtype + * reduction in the constraintType) when possible. + * @param noIndexSignatures Indicates if _string_ index signatures should be elided. (other index signatures are always reported) + */ + function getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) { + var typeParameter = getTypeParameterFromMappedType(type); + var constraintType = getConstraintTypeFromMappedType(type); + var nameType = getNameTypeFromMappedType(type.target || type); + if (!nameType && !noIndexSignatures) { + // no mapping and no filtering required, just quickly bail to returning the constraint in the common case + return constraintType; + } + var keyTypes = []; + if (isMappedTypeWithKeyofConstraintDeclaration(type)) { + // We have a { [P in keyof T]: X } + // `getApparentType` on the T in a generic mapped type can trigger a circularity + // (conditionals and `infer` types create a circular dependency in the constraint resolution) + // so we only eagerly manifest the keys if the constraint is nongeneric + if (!isGenericIndexType(constraintType)) { + var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + } + else { + // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later + // since it's not safe to resolve the shape of modifier type + return getIndexTypeForGenericType(type, stringsOnly); + } + } + else { + forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType); + } + if (isGenericIndexType(constraintType)) { // include the generic component in the resulting type + forEachType(constraintType, addMemberForKeyType); + } + // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, + // so we can return the union that preserves aliases/origin data if possible + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + return constraintType; + } + return result; + function addMemberForKeyType(keyType) { + var propNameType = nameType ? instantiateType(nameType, appendTypeMapping(type.mapper, typeParameter, keyType)) : keyType; + // `keyof` currently always returns `string | number` for concrete `string` index signatures - the below ternary keeps that behavior for mapped types + // See `getLiteralTypeFromProperties` where there's a similar ternary to cause the same behavior. + keyTypes.push(propNameType === stringType ? stringOrNumberType : propNameType); + } } // 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. Specifically, we only @@ -59020,10 +60231,13 @@ var ts; } return neverType; } + function isKeyTypeIncluded(keyType, include) { + return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + } function getLiteralTypeFromProperties(type, include, includeOrigin) { var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; 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 ? + var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); @@ -59034,7 +60248,7 @@ var ts; 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) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, noIndexSignatures) : + ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 /* Unknown */ ? neverType : type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : @@ -59055,15 +60269,15 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 139 /* KeyOfKeyword */: + case 140 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 152 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 149 /* SymbolKeyword */ + case 153 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 150 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 143 /* ReadonlyKeyword */: + case 144 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -59232,7 +60446,7 @@ var ts; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 205 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 206 /* ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { if (accessFlags & 256 /* Contextual */) { @@ -59396,9 +60610,9 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 205 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 192 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 160 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 206 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 193 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 161 /* ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { @@ -59507,12 +60721,6 @@ var ts; } return type[cache] = type; } - function isConditionalTypeAlwaysTrueDisregardingInferTypes(type) { - var extendsInferParamMapper = type.root.inferTypeParameters && createTypeMapper(type.root.inferTypeParameters, ts.map(type.root.inferTypeParameters, function () { return wildcardType; })); - var checkType = type.checkType; - var extendsType = type.extendsType; - return isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(instantiateType(extendsType, extendsInferParamMapper))); - } function getSimplifiedConditionalType(type, writing) { var checkType = type.checkType; var extendsType = type.extendsType; @@ -59584,7 +60792,7 @@ var ts; // 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 !== 192 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 193 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { if (objectType.flags & 3 /* AnyOrUnknown */) { @@ -59685,10 +60893,18 @@ var ts; function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { var result; var extraTypes; + var tailCount = 0; // 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 instantiation depth limiter. + // purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of + // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive + // cases we increment the tail recursion counter and stop after 1000 iterations. while (true) { + if (tailCount === 1000) { + error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); + result = errorType; + break; + } var isUnwrapped = isTypicalNondistributiveConditional(root); var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper); var checkTypeInstantiable = isGenericType(checkType); @@ -59732,6 +60948,9 @@ var ts; root = newRoot; continue; } + if (canTailRecurse(falseType_1, mapper)) { + continue; + } } result = instantiateType(falseType_1, mapper); break; @@ -59742,7 +60961,12 @@ var ts; // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { - result = instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper); + var trueType_1 = getTypeFromTypeNode(root.node.trueType); + var trueMapper = combinedMapper || mapper; + if (canTailRecurse(trueType_1, trueMapper)) { + continue; + } + result = instantiateType(trueType_1, trueMapper); break; } } @@ -59758,6 +60982,32 @@ var ts; break; } return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result; + // We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and + // (b) are non distributive, have a check type that is unaffected by instantiation, or have a non-union check + // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail + // recursion counter for those. + function canTailRecurse(newType, newMapper) { + if (newType.flags & 16777216 /* Conditional */ && newMapper) { + var newRoot = newType.root; + if (newRoot.outerTypeParameters) { + var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); + var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); + var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); + var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + root = newRoot; + mapper = newRootMapper; + aliasSymbol = undefined; + aliasTypeArguments = undefined; + if (newRoot.aliasSymbol) { + tailCount++; + } + return true; + } + } + } + return false; + } } function getTrueTypeFromConditionalType(type) { return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(getTypeFromTypeNode(type.root.node.trueType), type.mapper)); @@ -59779,6 +61029,10 @@ var ts; } return result; } + function isDistributionDependent(root) { + return root.isDistributive && (isTypeParameterPossiblyReferenced(root.checkType, root.node.trueType) || + isTypeParameterPossiblyReferenced(root.checkType, root.node.falseType)); + } function getTypeFromConditionalTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -59913,7 +61167,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 143 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 144 /* ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -60156,7 +61410,7 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 256 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 257 /* InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -60191,17 +61445,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 189 /* ParenthesizedType */: + case 190 /* ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 182 /* TupleType */: + case 183 /* TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 184 /* RestType */ || node.kind === 195 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 185 /* RestType */ || node.kind === 196 /* NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 181 /* ArrayType */: + case 182 /* ArrayType */: return node.elementType; } return undefined; @@ -60217,99 +61471,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 129 /* AnyKeyword */: - case 307 /* JSDocAllType */: - case 308 /* JSDocUnknownType */: + case 130 /* AnyKeyword */: + case 310 /* JSDocAllType */: + case 311 /* JSDocUnknownType */: return anyType; - case 153 /* UnknownKeyword */: + case 154 /* UnknownKeyword */: return unknownType; - case 148 /* StringKeyword */: + case 149 /* StringKeyword */: return stringType; - case 145 /* NumberKeyword */: + case 146 /* NumberKeyword */: return numberType; - case 156 /* BigIntKeyword */: + case 157 /* BigIntKeyword */: return bigintType; - case 132 /* BooleanKeyword */: + case 133 /* BooleanKeyword */: return booleanType; - case 149 /* SymbolKeyword */: + case 150 /* SymbolKeyword */: return esSymbolType; case 114 /* VoidKeyword */: return voidType; - case 151 /* UndefinedKeyword */: + case 152 /* UndefinedKeyword */: return undefinedType; 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 142 /* NeverKeyword */: + case 143 /* NeverKeyword */: return neverType; - case 146 /* ObjectKeyword */: + case 147 /* ObjectKeyword */: return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 137 /* IntrinsicKeyword */: + case 138 /* IntrinsicKeyword */: return intrinsicMarkerType; - case 190 /* ThisType */: + case 191 /* 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 194 /* LiteralType */: + case 195 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 176 /* TypeReference */: + case 177 /* TypeReference */: return getTypeFromTypeReference(node); - case 175 /* TypePredicate */: + case 176 /* TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 179 /* TypeQuery */: + case 180 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 181 /* ArrayType */: - case 182 /* TupleType */: + case 182 /* ArrayType */: + case 183 /* TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 183 /* OptionalType */: + case 184 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 185 /* UnionType */: + case 186 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 186 /* IntersectionType */: + case 187 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 309 /* JSDocNullableType */: + case 312 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 311 /* JSDocOptionalType */: + case 314 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 195 /* NamedTupleMember */: + case 196 /* NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 189 /* ParenthesizedType */: - case 310 /* JSDocNonNullableType */: - case 304 /* JSDocTypeExpression */: + case 190 /* ParenthesizedType */: + case 313 /* JSDocNonNullableType */: + case 307 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 184 /* RestType */: + case 185 /* RestType */: return getTypeFromRestTypeNode(node); - case 313 /* JSDocVariadicType */: + case 316 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 177 /* FunctionType */: - case 178 /* ConstructorType */: - case 180 /* TypeLiteral */: - case 317 /* JSDocTypeLiteral */: - case 312 /* JSDocFunctionType */: - case 318 /* JSDocSignature */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: + case 181 /* TypeLiteral */: + case 320 /* JSDocTypeLiteral */: + case 315 /* JSDocFunctionType */: + case 321 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 191 /* TypeOperator */: + case 192 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 192 /* IndexedAccessType */: + case 193 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 193 /* MappedType */: + case 194 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 187 /* ConditionalType */: + case 188 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 188 /* InferType */: + case 189 /* InferType */: return getTypeFromInferTypeNode(node); - case 196 /* TemplateLiteralType */: + case 197 /* TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 198 /* ImportType */: + case 199 /* 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 79 /* Identifier */: - case 159 /* QualifiedName */: - case 204 /* PropertyAccessExpression */: + case 160 /* QualifiedName */: + case 205 /* PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -60514,8 +61768,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - 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); + return !(node.parent.kind === 177 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 199 /* 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 @@ -60524,7 +61778,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 === 233 /* Block */ || n.kind === 187 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 234 /* Block */ || n.kind === 188 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -60533,15 +61787,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 190 /* ThisType */: + case 191 /* ThisType */: return !!tp.isThisType; case 79 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 179 /* TypeQuery */: + case 180 /* TypeQuery */: return true; - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -60576,9 +61830,11 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t !== errorType) { + if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { - if (isArrayType(t)) { + var constraint = void 0; + if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && + (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } if (isGenericTupleType(t)) { @@ -60618,7 +61874,7 @@ var ts; } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); - return elementType === errorType ? errorType : + return isErrorType(elementType) ? errorType : createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType))); } function instantiateMappedTupleType(tupleType, mappedType, mapper) { @@ -60669,27 +61925,21 @@ var ts; var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments); var result = root.instantiations.get(id); if (!result) { - var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments); - result = instantiateConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments); + var newMapper_1 = createTypeMapper(root.outerTypeParameters, typeArguments); + var checkType_1 = root.checkType; + var distributionType = root.isDistributive ? getMappedType(checkType_1, newMapper_1) : undefined; + // Distributive conditional types are distributed over union types. For example, when the + // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the + // result is (A extends U ? X : Y) | (B extends U ? X : Y). + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + mapTypeWithAlias(distributionType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : + getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); } return result; } return type; } - function instantiateConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) { - // Check if we have a conditional type where the check type is a naked type parameter. If so, - // the conditional type is distributive over union types and when T is instantiated to a union - // type A | B, we produce (A extends U ? X : Y) | (B extends U ? X : Y). - if (root.isDistributive) { - var checkType_1 = root.checkType; - var instantiatedType = getMappedType(checkType_1, mapper); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { - return mapTypeWithAlias(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }, aliasSymbol, aliasTypeArguments); - } - } - return getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments); - } function instantiateType(type, mapper) { return type && mapper ? instantiateTypeWithAlias(type, mapper, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined) : type; } @@ -60697,10 +61947,10 @@ var ts; if (!couldContainTypeVariables(type)) { return type; } - if (instantiationDepth === 50 || instantiationCount >= 5000000) { - // We have reached 50 recursive type instantiations and there is a very high likelyhood we're dealing - // with a combination of infinite generic types that perpetually generate new type identities. We stop - // the recursion here by yielding the error type. + if (instantiationDepth === 100 || instantiationCount >= 5000000) { + // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement + // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types + // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; @@ -60818,35 +62068,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 168 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: - case 167 /* MethodDeclaration */: - case 254 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 168 /* MethodDeclaration */: + case 255 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 284 /* JsxAttributes */: + case 285 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 283 /* JsxAttribute */: { + case 284 /* 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 286 /* JsxExpression */: { + case 287 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g

) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -60860,10 +62110,10 @@ var ts; } 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 !== 233 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 234 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { - return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && + return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { @@ -60964,23 +62214,23 @@ var ts; return true; } switch (node.kind) { - case 286 /* JsxExpression */: - case 210 /* ParenthesizedExpression */: + case 287 /* JsxExpression */: + case 211 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: switch (node.operatorToken.kind) { case 63 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 284 /* JsxAttributes */: + case 285 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -61084,24 +62334,29 @@ var ts; 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; - } - else { + reportedError = true; + if (!elaborated) { // Issue error on the prop itself, since the prop couldn't elaborate the error var resultObj = errorOutputContainer || {}; // Use the expression type, if available var specificSource = next ? checkExpressionForMutableLocationWithContextualType(next, sourcePropType) : sourcePropType; - var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); - if (result && specificSource !== sourcePropType) { - // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType - checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); + if (exactOptionalPropertyTypes && isExactOptionalPropertyMismatch(specificSource, targetPropType)) { + var diag = ts.createDiagnosticForNode(prop, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target, typeToString(specificSource), typeToString(targetPropType)); + diagnostics.add(diag); + resultObj.errors = [diag]; + } + else { + 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); + var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); + if (result && specificSource !== sourcePropType) { + // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType + checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); + } } if (resultObj.errors) { var reportedDiag = resultObj.errors[resultObj.errors.length - 1]; @@ -61122,7 +62377,6 @@ var ts; } } } - reportedError = true; } } } @@ -61185,7 +62439,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 286 /* JsxExpression */: + case 287 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -61194,9 +62448,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 276 /* JsxElement */: - case 277 /* JsxSelfClosingElement */: - case 280 /* JsxFragment */: + case 277 /* JsxElement */: + case 278 /* JsxSelfClosingElement */: + case 281 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -61344,11 +62598,11 @@ var ts; } _b = prop.kind; switch (_b) { - 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]; + case 172 /* SetAccessor */: return [3 /*break*/, 2]; + case 171 /* GetAccessor */: return [3 /*break*/, 2]; + case 168 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 295 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 294 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -61425,8 +62679,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 167 /* MethodDeclaration */ && - kind !== 166 /* MethodSignature */ && kind !== 169 /* Constructor */; + var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 168 /* MethodDeclaration */ && + kind !== 167 /* MethodSignature */ && kind !== 170 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -61731,7 +62985,8 @@ var ts; var sourceStack; var targetStack; var maybeCount = 0; - var depth = 0; + var sourceDepth = 0; + var targetDepth = 0; var expandingFlags = 0 /* None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid @@ -61739,12 +62994,12 @@ var ts; var incompatibleStack = []; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack.length) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -61838,7 +63093,7 @@ var ts; path = "" + str; } // Otherwise write a dotted name if possible - else if (ts.isIdentifierText(str, compilerOptions.target)) { + else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { path = path + "." + str; } // Failing that, check if the name is already a computed name @@ -61959,10 +63214,25 @@ var ts; else if (sourceType === targetType) { message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated; } + else if (exactOptionalPropertyTypes && getExactOptionalUnassignableProperties(source, target).length) { + message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; + } else { + if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); + if (suggestedType) { + reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); + return; + } + } message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1; } } + else if (message === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1 + && exactOptionalPropertyTypes + && getExactOptionalUnassignableProperties(source, target).length) { + message = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; + } reportError(message, generalizedSourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { @@ -62009,13 +63279,17 @@ var ts; } return true; } + function isRelatedToWorker(source, target, reportErrors) { + return isRelatedTo(source, target, 3 /* Both */, reportErrors); + } /** * Compare two types and return * * Ternary.True if they are related with no assumptions, * * Ternary.Maybe if they are related with assumptions of other relationships, or * * Ternary.False if they are not related. */ - function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) { + function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { + if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } if (reportErrors === void 0) { reportErrors = false; } if (intersectionState === void 0) { intersectionState = 0 /* None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, @@ -62036,7 +63310,7 @@ var ts; if (source === target) return -1 /* True */; if (relation === identityRelation) { - return isIdenticalTo(source, target); + return isIdenticalTo(source, target, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, @@ -62087,8 +63361,8 @@ var ts; var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); var calls = getSignaturesOfType(source, 0 /* Call */); var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, /*reportErrors*/ false)) { + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { @@ -62100,16 +63374,15 @@ var ts; traceUnionsOrIntersectionsTooLarge(source, target); var result = 0 /* False */; var saveErrorInfo = captureErrorCalculationState(); - // Note that these checks are specifically ordered to produce correct results. In particular, - // we need to deconstruct unions before intersections (because unions are always at the top), - // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) { - result = getConstituentCount(source) * getConstituentCount(target) >= 4 ? - recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */) : - structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */); + if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) { + // We skip caching when source or target is a union with no more than three constituents. + result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */); + } + else if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) { + result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags); } if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) { - if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) { resetErrorInfo(saveErrorInfo); } } @@ -62131,7 +63404,7 @@ var ts; if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { + if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); } } @@ -62155,7 +63428,7 @@ var ts; if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 524288 /* NonInferrableType */); }))) { inPropertyCheck = true; - result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); + result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); inPropertyCheck = false; } reportErrorResults(source, target, result, isComparingJsxAttributes); @@ -62187,7 +63460,7 @@ var ts; var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); - if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType && + if (!isErrorType(intrinsicAttributes) && !isErrorType(intrinsicClassAttributes) && (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) { // do not report top error return result; @@ -62230,7 +63503,7 @@ var ts; } } } - function isIdenticalTo(source, target) { + function isIdenticalTo(source, target, recursionFlags) { if (source.flags !== target.flags) return 0 /* False */; if (source.flags & 67358815 /* Singleton */) @@ -62243,7 +63516,7 @@ var ts; } return result_7; } - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); } function getTypeOfPropertyInTypes(types, name) { var appendPropType = function (propTypes, type) { @@ -62324,7 +63597,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -62364,7 +63637,7 @@ var ts; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); if (related) { return related; } @@ -62372,14 +63645,14 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); if (related) { return related; } } if (reportErrors) { var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); - isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], 2 /* Target */, /*reportErrors*/ true); } return 0 /* False */; } @@ -62388,7 +63661,7 @@ var ts; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { return 0 /* False */; } @@ -62403,7 +63676,7 @@ var ts; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } @@ -62433,13 +63706,13 @@ var ts; // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { return 0 /* False */; } @@ -62471,31 +63744,31 @@ var ts; // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } else if (variance === 3 /* Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { @@ -62511,7 +63784,7 @@ var ts; // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) { + function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { return 0 /* False */; } @@ -62555,7 +63828,7 @@ var ts; return 3 /* Maybe */; } } - if (depth === 100) { + if (sourceDepth === 100 || targetDepth === 100) { overflow = true; return 0 /* False */; } @@ -62563,14 +63836,19 @@ var ts; var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, depth)) - expandingFlags |= 1 /* Source */; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) - expandingFlags |= 2 /* Target */; + if (recursionFlags & 1 /* Source */) { + sourceStack[sourceDepth] = source; + sourceDepth++; + if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* Source */; + } + if (recursionFlags & 2 /* Target */) { + targetStack[targetDepth] = target; + targetDepth++; + if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* Target */; + } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { @@ -62586,17 +63864,23 @@ var ts; sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, targetIdStack: targetStack.map(function (t) { return t.id; }), - depth: depth, + depth: sourceDepth, + targetDepth: targetDepth }); } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3 /* Maybe */; if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } + if (recursionFlags & 1 /* Source */) { + sourceDepth--; + } + if (recursionFlags & 2 /* Target */) { + targetDepth--; + } expandingFlags = saveExpandingFlags; - depth--; if (result) { - if (result === -1 /* True */ || depth === 0) { + if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { if (result === -1 /* True */ || result === 3 /* Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. @@ -62650,7 +63934,7 @@ var ts; if (constraints !== source.types) { source = getIntersectionType(constraints); if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, /*reportErrors*/ false); + return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); } } } @@ -62672,22 +63956,22 @@ var ts; var flags = source.flags & target.flags; if (relation === identityRelation && !(flags & 524288 /* Object */)) { if (flags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, /*reportErrors*/ false); + return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); } var result_8 = 0 /* False */; if (flags & 8388608 /* IndexedAccess */) { - if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { - if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { + if (result_8 = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { return result_8; } } } if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result_8 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { - if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { - if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { - if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { + if (result_8 = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { return result_8; } } @@ -62696,7 +63980,7 @@ var ts; } } if (flags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); + return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); } return 0 /* False */; } @@ -62721,47 +64005,71 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0]))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { return result; } if (target.flags & 262144 /* TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) { + if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { return result; } } } } else if (target.flags & 4194304 /* Index */) { - var targetType = target.type; + var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. if (source.flags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType, source.type, /*reportErrors*/ false)) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { return result; } } - if (isTupleType(targetType)) { + if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType), reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { return result; } } else { // A type S is assignable to keyof T if S is assignable to keyof C, where C is the // simplified form of T or, if T doesn't simplify, the constraint of T. - var constraint = getSimplifiedTypeOrConstraint(targetType); + var constraint = getSimplifiedTypeOrConstraint(targetType_1); if (constraint) { // We require Ternary.True here such that circular constraints don't cause // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1 /* True */) { + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { + return -1 /* True */; + } + } + else if (isGenericMappedType(targetType_1)) { + // generic mapped types that don't simplify or have a constraint still have a very simple set of keys we can compare against + // - their nameType or constraintType. + // In many ways, this comparison is a deferred version of what `getIndexTypeForMappedType` does to actually resolve the keys for _non_-generic types + var nameType_1 = getNameTypeFromMappedType(targetType_1); + var constraintType = getConstraintTypeFromMappedType(targetType_1); + var targetKeys = void 0; + if (nameType_1 && isMappedTypeWithKeyofConstraintDeclaration(targetType_1)) { + // we need to get the apparent mappings and union them with the generic mappings, since some properties may be + // missing from the `constraintType` which will otherwise be mapped in the object + var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); + var mappedKeys_1 = []; + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); + // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) + targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); + } + else { + targetKeys = nameType_1 || constraintType; + } + if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { return -1 /* True */; } } @@ -62771,8 +64079,8 @@ var ts; if (source.flags & 8388608 /* IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -62797,7 +64105,7 @@ var ts; // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -62811,39 +64119,60 @@ var ts; originalErrorInfo = undefined; } } - else if (isGenericMappedType(target) && !target.declaration.nameType) { - // A source type T is related to a target type { [P in X]: T[P] } - var template = getTemplateTypeFromMappedType(target); + else if (isGenericMappedType(target) && relation !== identityRelation) { + // Check if source type `S` is related to target type `{ [P in Q]: T }` or `{ [P in Q as R]: T}`. + var keysRemapped = !!target.declaration.nameType; + var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8 /* ExcludeOptional */)) { - if (template.flags & 8388608 /* IndexedAccess */ && template.objectType === source && - template.indexType === getTypeParameterFromMappedType(target)) { + // If the mapped type has shape `{ [P in Q]: T[P] }`, + // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. + if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + templateType.indexType === getTypeParameterFromMappedType(target)) { return -1 /* True */; } if (!isGenericMappedType(source)) { - var targetConstraint = getConstraintTypeFromMappedType(target); + // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. + // If target has shape `{ [P in Q]: T }`, then its keys have type `Q`. + var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); + // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); var includeOptional = modifiers & 4 /* IncludeOptional */; - var filteredByApplicability = includeOptional ? intersectTypes(targetConstraint, sourceKeys) : undefined; - // A source type T is related to a target type { [P in Q]: X } if Q is related to keyof T and T[Q] is related to X. - // A source type T is related to a target type { [P in Q]?: X } if some constituent Q' of Q is related to keyof T and T[Q'] is related to X. + var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; + // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. + // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. + // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. + // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetConstraint, sourceKeys)) { - var templateType = getTemplateTypeFromMappedType(target); + : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); - // Fastpath: When the template has the form Obj[P] where P is the mapped type parameter, directly compare `source` with `Obj` - // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `source[P]` - var nonNullComponent = extractTypesOfKind(templateType, ~98304 /* Nullable */); - if (nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, reportErrors)) { + // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` + // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { return result; } } else { - var indexingType = filteredByApplicability ? getIntersectionType([filteredByApplicability, typeParameter]) : typeParameter; + // We need to compare the type of a property on the source type `S` to the type of the same property on the target type, + // so we need to construct an indexing type representing a property, and then use indexing type to index the source type for comparison. + // If the target type has shape `{ [P in Q]: T }`, then a property of the target has type `P`. + // If the target type has shape `{ [P in Q]?: T }`, then a property of the target has type `P`, + // but the property is optional, so we only want to compare properties `P` that are common between `keyof S` and `Q`. + // If the target type has shape `{ [P in Q as R]: T }`, then a property of the target has type `R`. + // If the target type has shape `{ [P in Q as R]?: T }`, then a property of the target has type `R`, + // but the property is optional, so we only want to compare properties `R` that are common between `keyof S` and `R`. + var indexingType = keysRemapped + ? (filteredByApplicability || targetKeys) + : filteredByApplicability + ? getIntersectionType([filteredByApplicability, typeParameter]) + : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); - if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { + // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { return result; } } @@ -62854,41 +64183,40 @@ var ts; } } else if (target.flags & 16777216 /* Conditional */) { - var c = target; - // Check if the conditional is always true or always false but still deferred for distribution purposes - var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); - var skipFalse = !skipTrue && isConditionalTypeAlwaysTrueDisregardingInferTypes(c); - // Instantiate with a replacement mapper if the conditional is distributive, replacing the check type with a clone of itself, - // this way {x: string | number, y: string | number} -> (T extends T ? { x: T, y: T } : never) appropriately _fails_ when - // T = string | number (since that will end up distributing and producing `{x: string, y: string} | {x: number, y: number}`, - // to which `{x: string | number, y: string | number}` isn't assignable) - var distributionMapper = void 0; - var checkVar = getActualTypeVariable(c.root.checkType); - if (c.root.isDistributive && checkVar.flags & 262144 /* TypeParameter */) { - var newParam = cloneTypeParameter(checkVar); - distributionMapper = prependTypeMapping(checkVar, newParam, c.mapper); - newParam.mapper = distributionMapper; - } - // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - var localResult = void 0; - if (skipTrue || (localResult = isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.trueType), distributionMapper) : getTrueTypeFromConditionalType(c), /*reportErrors*/ false))) { - if (!skipFalse) { - localResult = (localResult || 3 /* Maybe */) & isRelatedTo(source, distributionMapper ? instantiateType(getTypeFromTypeNode(c.root.node.falseType), distributionMapper) : getFalseTypeFromConditionalType(c), /*reportErrors*/ false); - } - } - if (localResult) { + // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive + // conditional type and bail out with a Ternary.Maybe result. + if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { resetErrorInfo(saveErrorInfo); - return localResult; + return 3 /* Maybe */; + } + var c = target; + // We check for a relationship to a conditional type target only when the conditional type has no + // 'infer' positions and is not distributive or is distributive but doesn't reference the check type + // parameter in either of the result types. + if (!c.root.inferTypeParameters && !isDistributionDependent(c.root)) { + // Check if the conditional is always true or always false but still deferred for distribution purposes. + var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); + var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); + // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) + if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result) { + resetErrorInfo(saveErrorInfo); + return result; + } + } } } else if (target.flags & 134217728 /* TemplateLiteral */) { if (source.flags & 134217728 /* TemplateLiteral */) { + if (relation === comparableRelation) { + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } - var result_9 = inferTypesFromTemplateLiteralType(source, target); - if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { + if (isTypeMatchedByTemplateLiteralType(source, target)) { return -1 /* True */; } } @@ -62898,34 +64226,33 @@ var ts; var constraint = getConstraintOfType(source); if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */), 3 /* Both */)) { resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { + else if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } - else if (source.flags & 134217728 /* TemplateLiteral */) { + else if (source.flags & 134217728 /* TemplateLiteral */ && !(target.flags & 524288 /* Object */)) { if (!(target.flags & 134217728 /* TemplateLiteral */)) { - var baseConstraint = getBaseConstraintOfType(source); - var constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType; - if (result = isRelatedTo(constraint, target, reportErrors)) { + var constraint = getBaseConstraintOfType(source); + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } @@ -62933,20 +64260,26 @@ var ts; } else if (source.flags & 268435456 /* StringMapping */) { if (target.flags & 268435456 /* StringMapping */ && source.symbol === target.symbol) { - if (result = isRelatedTo(source.type, target.type, reportErrors)) { + if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, reportErrors))) { + if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 16777216 /* Conditional */) { + // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive + // conditional type and bail out with a Ternary.Maybe result. + if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { + resetErrorInfo(saveErrorInfo); + return 3 /* Maybe */; + } if (target.flags & 16777216 /* Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, @@ -62956,15 +64289,15 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); } if (result) { resetErrorInfo(saveErrorInfo); @@ -62977,17 +64310,17 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { + if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } } } // conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O` - // when `O` is a conditional (`never` is trivially aissgnable to `O`, as is `O`!). + // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { + if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { resetErrorInfo(saveErrorInfo); return result; } @@ -63033,7 +64366,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, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple @@ -63078,9 +64411,9 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) { var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); if (objectOnlyTarget.flags & 1048576 /* Union */) { - var result_10 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); - if (result_10) { - return result_10; + var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); + if (result_9) { + return result_9; } } } @@ -63152,13 +64485,13 @@ var ts; var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { - var result_11; + var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); } } } @@ -63290,7 +64623,7 @@ var ts; var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); @@ -63472,7 +64805,7 @@ var ts; var targetType = targetTypeArguments[i]; var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -63618,7 +64951,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) === 169 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 169 /* Constructor */)) { + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 170 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 170 /* Constructor */)) { var constructSignatureToString = function (signature) { return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); }; @@ -63666,7 +64999,7 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -63699,7 +65032,7 @@ var ts; var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) ? propType : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, reportErrors); + var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); @@ -63722,7 +65055,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -63743,7 +65076,7 @@ var ts; 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) : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { return 0 /* False */; @@ -63775,7 +65108,7 @@ var ts; 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)) { + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { return 0 /* False */; } } @@ -63823,6 +65156,18 @@ var ts; } return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */); } + function getExactOptionalUnassignableProperties(source, target) { + if (isTupleType(source) && isTupleType(target)) + return ts.emptyArray; + return getPropertiesOfType(target) + .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); + } + function isExactOptionalPropertyMismatch(source, target) { + return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + } + function getExactOptionalProperties(type) { + return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); + } function getBestMatchingType(source, target, isRelatedTo) { if (isRelatedTo === void 0) { isRelatedTo = compareTypesAssignable; } return findMatchingDiscriminantType(source, target, isRelatedTo, /*skipPartial*/ true) || @@ -64086,14 +65431,15 @@ var ts; // `type A = null extends T ? [A>] : [T]` // has expanded into `[A>>>>>]` // in such cases we need to terminate the expansion, and we do so here. - function isDeeplyNestedType(type, stack, depth) { - if (depth >= 5) { + function isDeeplyNestedType(type, stack, depth, maxDepth) { + if (maxDepth === void 0) { maxDepth = 5; } + if (depth >= maxDepth) { var identity_1 = getRecursionIdentity(type); var count = 0; for (var i = 0; i < depth; i++) { if (getRecursionIdentity(stack[i]) === identity_1) { count++; - if (count >= 5) { + if (count >= maxDepth) { return true; } } @@ -64329,7 +65675,7 @@ var ts; 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 */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 205 /* PropertyAccessExpression */) { return undefined; } } @@ -64821,12 +66167,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 219 /* BinaryExpression */: - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: + case 220 /* BinaryExpression */: + case 166 /* PropertyDeclaration */: + case 165 /* 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 162 /* Parameter */: + case 163 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -64834,30 +66180,31 @@ var ts; (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); - errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name)); + var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); + errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, typeName); return; } diagnostic = declaration.dotDotDotToken ? 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 201 /* BindingElement */: + case 202 /* 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 312 /* JSDocFunctionType */: + case 315 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 254 /* FunctionDeclaration */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 255 /* FunctionDeclaration */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 212 /* FunctionExpression */: + case 213 /* 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); @@ -64871,7 +66218,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 193 /* MappedType */: + case 194 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -65013,8 +66360,8 @@ var ts; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - 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"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 258 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 303 /* SourceFile */ ? true : n.kind === 260 /* ModuleDeclaration */ ? false : "quit"; })); } return false; } @@ -65177,6 +66524,17 @@ var ts; function isFromInferenceBlockedSource(type) { return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag)); } + function templateLiteralTypesDefinitelyUnrelated(source, target) { + // Two template literal types with diffences in their starting or ending text spans are definitely unrelated. + var sourceStart = source.texts[0]; + var targetStart = target.texts[0]; + var sourceEnd = source.texts[source.texts.length - 1]; + var targetEnd = target.texts[target.texts.length - 1]; + var startLen = Math.min(sourceStart.length, targetStart.length); + var endLen = Math.min(sourceEnd.length, targetEnd.length); + return sourceStart.slice(0, startLen) !== targetStart.slice(0, startLen) || + sourceEnd.slice(sourceEnd.length - endLen) !== targetEnd.slice(targetEnd.length - endLen); + } function isValidBigIntString(s) { var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); var success = true; @@ -65217,6 +66575,10 @@ var ts; inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; } + function isTypeMatchedByTemplateLiteralType(source, target) { + var inferences = inferTypesFromTemplateLiteralType(source, target); + return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); + } function getStringLikeTypeForType(type) { return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } @@ -65763,8 +67125,16 @@ var ts; function inferToTemplateLiteralType(source, target) { var matches = inferTypesFromTemplateLiteralType(source, target); var types = target.types; - for (var i = 0; i < types.length; i++) { - inferFromTypes(matches ? matches[i] : neverType, types[i]); + // When the target template literal contains only placeholders (meaning that inference is intended to extract + // single characters and remainder strings) and inference fails to produce matches, we want to infer 'never' for + // each placeholder such that instantiation with the inferred value(s) produces 'never', a type for which an + // assignment check will fail. If we make no inferences, we'll likely end up with the constraint 'string' which, + // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might + // succeed. That would be a pointless and confusing outcome. + if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) { + for (var i = 0; i < types.length; i++) { + inferFromTypes(matches ? matches[i] : neverType, types[i]); + } } } function inferFromObjectTypes(source, target) { @@ -65887,7 +67257,7 @@ 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 === 167 /* MethodDeclaration */ || kind === 166 /* MethodSignature */ || kind === 169 /* Constructor */; + bivariant = bivariant || kind === 168 /* MethodDeclaration */ || kind === 167 /* MethodSignature */ || kind === 170 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -65985,17 +67355,16 @@ var ts; var inferredType = void 0; var signature = context.signature; if (signature) { - var inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined; + var inferredCovariantType_1 = inference.candidates ? getCovariantInference(inference, signature) : undefined; if (inference.contraCandidates) { - var inferredContravariantType = getContravariantInference(inference); // If we have both co- and contra-variant inferences, we prefer the contra-variant inference - // unless the co-variant inference is a subtype and not 'never'. - inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) && - isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ? - inferredCovariantType : inferredContravariantType; + // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? + inferredCovariantType_1 : getContravariantInference(inference); } - else if (inferredCovariantType) { - inferredType = inferredCovariantType; + else if (inferredCovariantType_1) { + inferredType = inferredCovariantType_1; } else if (context.flags & 1 /* NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. @@ -66083,7 +67452,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 === 292 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 295 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -66096,8 +67465,7 @@ 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, - /*issueSuggestions*/ true) || unknownSymbol; + /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; } @@ -66105,7 +67473,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 === 179 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 159 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 180 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 160 /* 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 @@ -66114,18 +67482,21 @@ var ts; function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { case 79 /* Identifier */: - var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + if (!ts.isThisInTypeQuery(node)) { + var symbol = getResolvedSymbol(node); + return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + } + // falls through case 108 /* ThisKeyword */: return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 228 /* NonNullExpression */: - case 210 /* ParenthesizedExpression */: + case 229 /* NonNullExpression */: + case 211 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -66136,16 +67507,16 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 210 /* ParenthesizedExpression */: - case 228 /* NonNullExpression */: + case 211 /* ParenthesizedExpression */: + case 229 /* NonNullExpression */: return isMatchingReference(source, target.expression); - case 219 /* BinaryExpression */: + case 220 /* 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 229 /* MetaProperty */: - return target.kind === 229 /* MetaProperty */ + case 230 /* MetaProperty */: + return target.kind === 230 /* MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; case 79 /* Identifier */: @@ -66153,35 +67524,29 @@ var ts; return ts.isThisInTypeQuery(source) ? target.kind === 108 /* ThisKeyword */ : target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 252 /* VariableDeclaration */ || target.kind === 201 /* BindingElement */) && + (target.kind === 253 /* VariableDeclaration */ || target.kind === 202 /* 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 */: + case 229 /* NonNullExpression */: + case 211 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); } return false; } - // 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 === 219 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && - (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); - } function getPropertyAccess(expr) { if (ts.isAccessExpression(expr)) { return expr; @@ -66207,9 +67572,9 @@ var ts; } function getAccessedPropertyName(access) { 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) : + return access.kind === 205 /* PropertyAccessExpression */ ? access.name.escapedText : + access.kind === 206 /* ElementAccessExpression */ && ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + access.kind === 202 /* BindingElement */ && (propertyName = getDestructuringPropertyName(access)) ? ts.escapeLeadingUnderscores(propertyName) : undefined; } function containsMatchingReference(source, target) { @@ -66237,7 +67602,7 @@ var ts; if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && - !maybeTypeOfKind(getTypeOfSymbol(prop), 465829888 /* Instantiable */ & ~134217728 /* TemplateLiteral */); + !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; } @@ -66301,8 +67666,9 @@ var ts; // constituent types keyed by the literal types of the property by that name in each constituent type. function getKeyPropertyName(unionType) { var types = unionType.types; - // We only construct maps for large unions with non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */) { + // We only construct maps for unions with many non-primitive constituents. + if (types.length < 10 || ts.getObjectFlags(unionType) & 65536 /* PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { @@ -66333,9 +67699,9 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 291 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 294 /* PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); - var propType = propNode && getTypeOfExpression(propNode.initializer); + var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); } function isOrContainsMatchingReference(source, target) { @@ -66350,7 +67716,7 @@ var ts; } } } - if (expression.expression.kind === 204 /* PropertyAccessExpression */ && + if (expression.expression.kind === 205 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -66511,15 +67877,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 202 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 291 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 203 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 294 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 219 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 242 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 220 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 243 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -66536,21 +67902,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: return stringType; - case 242 /* ForOfStatement */: + case 243 /* ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 213 /* DeleteExpression */: + case 214 /* DeleteExpression */: return undefinedType; - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 223 /* SpreadElement */: + case 224 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -66558,7 +67924,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 199 /* ObjectBindingPattern */ ? + var type = pattern.kind === 200 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -66576,30 +67942,30 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 241 /* ForInStatement */) { + if (node.parent.parent.kind === 242 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 242 /* ForOfStatement */) { + if (node.parent.parent.kind === 243 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 252 /* VariableDeclaration */ ? + return node.kind === 253 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 252 /* VariableDeclaration */ && node.initializer && + return node.kind === 253 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 201 /* BindingElement */ && node.parent.kind === 219 /* BinaryExpression */ && + node.kind !== 202 /* BindingElement */ && node.parent.kind === 220 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: switch (node.operatorToken.kind) { case 63 /* EqualsToken */: case 75 /* BarBarEqualsToken */: @@ -66614,13 +67980,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - 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 ? + return parent.kind === 211 /* ParenthesizedExpression */ || + parent.kind === 220 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || + parent.kind === 220 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 287 /* CaseClause */) { + if (clause.kind === 288 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -66640,7 +68006,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 287 /* CaseClause */) { + if (clause.kind === 288 /* CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -66751,22 +68117,24 @@ var ts; mapType(type, mapper); } function getConstituentCount(type) { - return type.flags & 3145728 /* UnionOrIntersection */ ? type.types.length : 1; + return type.flags & 1048576 /* Union */ ? type.types.length : 1; } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); } - // Return a new type in which occurrences of the string and number primitive types in - // typeWithPrimitives have been replaced with occurrences of string literals and numeric - // literals in typeWithLiterals, respectively. + // Return a new type in which occurrences of the string, number and bigint primitives and placeholder template + // literal types in typeWithPrimitives have been replaced with occurrences of compatible and more specific types + // from typeWithLiterals. This is essentially a limited form of intersection between the two types. We avoid a + // true intersection because it is more costly and, when applied to union types, generates a large number of + // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256 /* NumberLiteral */) || - isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : + t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -66835,22 +68203,22 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 206 /* CallExpression */ + parent.parent.kind === 207 /* CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 205 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 206 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 219 /* BinaryExpression */ && + parent.parent.kind === 220 /* 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 === 252 /* VariableDeclaration */ || declaration.kind === 162 /* Parameter */ || - declaration.kind === 165 /* PropertyDeclaration */ || declaration.kind === 164 /* PropertySignature */) && - !!ts.getEffectiveTypeAnnotationNode(declaration); + function isDeclarationWithExplicitTypeAnnotation(node) { + return (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isParameter(node)) && + !!(ts.getEffectiveTypeAnnotationNode(node) || + ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { @@ -66868,7 +68236,7 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 242 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { @@ -66896,7 +68264,7 @@ var ts; return getExplicitThisType(node); case 106 /* SuperKeyword */: return checkSuperExpression(node); - case 204 /* PropertyAccessExpression */: { + case 205 /* PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -66914,7 +68282,7 @@ var ts; } return undefined; } - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -66928,7 +68296,7 @@ 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 === 236 /* ExpressionStatement */) { + if (node.parent.kind === 237 /* ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } else if (node.expression.kind !== 106 /* SuperKeyword */) { @@ -66971,8 +68339,8 @@ var ts; return result; } function isFalseExpression(expr) { - var node = ts.skipParentheses(expr); - return node.kind === 95 /* FalseKeyword */ || node.kind === 219 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); + return node.kind === 95 /* FalseKeyword */ || node.kind === 220 /* 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) { @@ -67089,11 +68457,12 @@ var ts; } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: + 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 */: + return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); + } + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -67104,7 +68473,6 @@ var ts; var key; var isKeySet = false; var flowDepth = 0; - var inlineLevel = 0; if (flowAnalysisDisabled) { return errorType; } @@ -67120,10 +68488,11 @@ 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 === 228 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 229 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } - return resultType; + // The non-null unknown type should never escape control flow analysis. + return resultType === nonNullUnknownType ? unknownType : resultType; function getOrSetCacheKey() { if (isKeySet) { return key; @@ -67204,8 +68573,8 @@ 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 !== 204 /* PropertyAccessExpression */ && - reference.kind !== 205 /* ElementAccessExpression */ && + reference.kind !== 205 /* PropertyAccessExpression */ && + reference.kind !== 206 /* ElementAccessExpression */ && reference.kind !== 108 /* ThisKeyword */) { flow = container.flowNode; continue; @@ -67230,7 +68599,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 252 /* VariableDeclaration */ || node.kind === 201 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 253 /* VariableDeclaration */ || node.kind === 202 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -67270,25 +68639,25 @@ 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 === 211 /* FunctionExpression */ || init.kind === 212 /* ArrowFunction */)) { + if (init && (init.kind === 212 /* FunctionExpression */ || init.kind === 213 /* 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 === 241 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 242 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } function narrowTypeByAssertion(type, expr) { - var node = ts.skipParentheses(expr); + var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); if (node.kind === 95 /* FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 219 /* BinaryExpression */) { + if (node.kind === 220 /* BinaryExpression */) { if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } @@ -67319,7 +68688,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 206 /* CallExpression */ ? + var expr = node.kind === 207 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -67327,7 +68696,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 206 /* CallExpression */) { + if (node.kind === 207 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -67375,7 +68744,7 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 214 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 215 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { @@ -67383,7 +68752,7 @@ 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 === 214 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + else if (expr.kind === 215 /* 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"); }); } } @@ -67566,7 +68935,7 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(discriminantType.flags & 131072 /* Never */) && isTypeComparableTo(discriminantType, narrowedPropType); + return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { @@ -67595,7 +68964,8 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return type.flags & 2 /* Unknown */ && assumeTrue ? nonNullUnknownType : + getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); @@ -67636,10 +69006,10 @@ var ts; var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 214 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 215 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 214 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 215 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -67674,6 +69044,9 @@ var ts; case 102 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); case 101 /* InKeyword */: + if (ts.isPrivateIdentifier(expr.left)) { + return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); + } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); if (leftType.flags & 128 /* StringLiteral */) { @@ -67703,6 +69076,22 @@ var ts; } return type; } + function narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue) { + var target = getReferenceCandidate(expr.right); + if (!isMatchingReference(reference, target)) { + return type; + } + ts.Debug.assertNode(expr.left, ts.isPrivateIdentifier); + var symbol = getSymbolForPrivateIdentifierExpression(expr.left); + if (symbol === undefined) { + return type; + } + var classSymbol = symbol.parent; + var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) + ? getTypeOfSymbol(classSymbol) + : getDeclaredTypeOfSymbol(classSymbol); + return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + } function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { // We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows: // When operator is === and type of value excludes undefined, null and undefined is removed from type of obj in true branch. @@ -67729,6 +69118,9 @@ var ts; assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); + if (assumeTrue && (type.flags & 2 /* Unknown */) && (operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */) && (valueType.flags & 65536 /* Null */)) { + return getUnionType([nullType, undefinedType]); + } if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; @@ -67748,7 +69140,7 @@ var ts; valueType.flags & 65536 /* Null */ ? assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; - return getTypeWithFacts(type, facts); + return type.flags & 2 /* Unknown */ && facts & (1048576 /* NENull */ | 2097152 /* NEUndefinedOrNull */) ? nonNullUnknownType : getTypeWithFacts(type, facts); } if (assumeTrue) { var filterFn = operator === 34 /* EqualsEqualsToken */ ? @@ -67777,15 +69169,10 @@ var ts; return type; } 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 === 219 /* BinaryExpression */) { - var expr = typeOfExpr.parent.parent; - if (expr.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { - return nonPrimitiveType; - } - } - return getUnionType([nonPrimitiveType, nullType]); + // The non-null unknown type is used to track whether a previous narrowing operation has removed the null type + // from the unknown type. For example, the expression `x && typeof x === 'object'` first narrows x to the non-null + // unknown type, and then narrows that to the non-primitive type. + return type === nonNullUnknownType ? nonPrimitiveType : getUnionType([nonPrimitiveType, nullType]); } var facts = assumeTrue ? typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : @@ -68017,16 +69404,7 @@ var ts; } function getNarrowedType(type, candidate, assumeTrue, isRelated) { if (!assumeTrue) { - return filterType(type, function (t) { - if (!isRelated(t, candidate)) { - return true; - } - var constraint = getBaseConstraintOfType(t); - if (constraint && constraint !== t) { - return !isRelated(constraint, candidate); - } - return false; - }); + return filterType(type, function (t) { return !isRelated(t, candidate); }); } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. @@ -68113,17 +69491,17 @@ var ts; // falls through case 108 /* ThisKeyword */: case 106 /* SuperKeyword */: - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 210 /* ParenthesizedExpression */: - case 228 /* NonNullExpression */: + case 211 /* ParenthesizedExpression */: + case 229 /* NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -68172,40 +69550,42 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 260 /* ModuleBlock */ || - node.kind === 300 /* SourceFile */ || - node.kind === 165 /* PropertyDeclaration */; + node.kind === 261 /* ModuleBlock */ || + node.kind === 303 /* SourceFile */ || + node.kind === 166 /* PropertyDeclaration */; }); } - // Check if a parameter is assigned anywhere within its declaring function. - function isParameterAssigned(symbol) { + // Check if a parameter or catch variable is assigned anywhere + function isSymbolAssigned(symbol) { if (!symbol.valueDeclaration) { return false; } - var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; - var links = getNodeLinks(func); + var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; + var links = getNodeLinks(parent); if (!(links.flags & 8388608 /* AssignmentsMarked */)) { links.flags |= 8388608 /* AssignmentsMarked */; - if (!hasParentWithAssignmentsMarked(func)) { - markParameterAssignments(func); + if (!hasParentWithAssignmentsMarked(parent)) { + markNodeAssignments(parent); } } return symbol.isAssigned || false; } function hasParentWithAssignmentsMarked(node) { - return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); + return !!ts.findAncestor(node.parent, function (node) { + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + }); } - function markParameterAssignments(node) { + function markNodeAssignments(node) { if (node.kind === 79 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 162 /* Parameter */) { + if (ts.isParameterOrCatchClauseVariable(symbol)) { symbol.isAssigned = true; } } } else { - ts.forEachChild(node, markParameterAssignments); + ts.forEachChild(node, markNodeAssignments); } } function isConstVariable(symbol) { @@ -68215,7 +69595,7 @@ var ts; function removeOptionalityFromDeclaredType(declaredType, declaration) { if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 162 /* Parameter */ && + declaration.kind === 163 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -68232,10 +69612,10 @@ var ts; // 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))); + return parent.kind === 205 /* PropertyAccessExpression */ || + parent.kind === 207 /* CallExpression */ && parent.expression === node || + parent.kind === 206 /* ElementAccessExpression */ && parent.expression === node && + !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); @@ -68265,7 +69645,19 @@ var ts; return substituteConstraints ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; } function isExportOrExportExpression(location) { - return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); }); + return !!ts.findAncestor(location, function (n) { + var parent = n.parent; + if (parent === undefined) { + return "quit"; + } + if (ts.isExportAssignment(parent)) { + return parent.expression === n && ts.isEntityNameExpression(n); + } + if (ts.isExportSpecifier(parent)) { + return parent.name === n || parent.propertyName === n; + } + return false; + }); } function markAliasReferenced(symbol, location) { if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { @@ -68303,7 +69695,7 @@ var ts; } var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 212 /* ArrowFunction */) { + if (container.kind === 213 /* 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 */)) { @@ -68328,7 +69720,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 === 255 /* ClassDeclaration */ + if (declaration.kind === 256 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -68340,12 +69732,12 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 224 /* ClassExpression */) { + else if (declaration.kind === 225 /* 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 !== 300 /* SourceFile */) { + while (container.kind !== 303 /* SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; @@ -68403,7 +69795,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 === 162 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 163 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -68412,9 +69804,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 === 211 /* FunctionExpression */ || - flowContainer.kind === 212 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && - (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isParameterAssigned(localOrExportSymbol))) { + while (flowContainer !== declarationContainer && (flowContainer.kind === 212 /* FunctionExpression */ || + flowContainer.kind === 213 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze @@ -68422,9 +69814,9 @@ 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 === 273 /* ExportSpecifier */) || - node.parent.kind === 228 /* NonNullExpression */ || - declaration.kind === 252 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 274 /* ExportSpecifier */) || + node.parent.kind === 229 /* NonNullExpression */ || + declaration.kind === 253 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -68463,7 +69855,7 @@ var ts; (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 290 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 291 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -68478,7 +69870,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, 253 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 254 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { @@ -68499,7 +69891,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, 253 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 254 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -68518,7 +69910,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 210 /* ParenthesizedExpression */) { + while (current.parent.kind === 211 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -68526,7 +69918,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 217 /* PrefixUnaryExpression */ || current.parent.kind === 218 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 218 /* PrefixUnaryExpression */ || current.parent.kind === 219 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } @@ -68539,7 +69931,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 165 /* PropertyDeclaration */ || container.kind === 169 /* Constructor */) { + if (container.kind === 166 /* PropertyDeclaration */ || container.kind === 170 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -68586,31 +69978,31 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 169 /* Constructor */) { + if (container.kind === 170 /* 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 === 212 /* ArrowFunction */) { + if (container.kind === 213 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 259 /* ModuleDeclaration */: + case 260 /* 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 258 /* EnumDeclaration */: + case 259 /* 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 169 /* Constructor */: + case 170 /* 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 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -68698,7 +70090,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 211 /* FunctionExpression */ && + if (container.kind === 212 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -68708,16 +70100,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 167 /* MethodDeclaration */ && - container.parent.kind === 203 /* ObjectLiteralExpression */ && + else if (container.kind === 168 /* MethodDeclaration */ && + container.parent.kind === 204 /* 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 === 211 /* FunctionExpression */ && - container.parent.kind === 291 /* PropertyAssignment */ && - container.parent.parent.kind === 203 /* ObjectLiteralExpression */ && + else if (container.kind === 212 /* FunctionExpression */ && + container.parent.kind === 294 /* PropertyAssignment */ && + container.parent.parent.kind === 204 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -68725,7 +70117,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 === 211 /* FunctionExpression */ && + else if (container.kind === 212 /* 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") && @@ -68750,7 +70142,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 312 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 315 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -68764,16 +70156,16 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 162 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 163 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 206 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 207 /* 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 === 212 /* ArrowFunction */) { + while (container && container.kind === 213 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -68786,14 +70178,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 160 /* ComputedPropertyName */; }); - if (current && current.kind === 160 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 161 /* ComputedPropertyName */; }); + if (current && current.kind === 161 /* 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 === 203 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 204 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -68801,7 +70193,7 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 169 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 170 /* 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.isStatic(container) || isCallExpression) { @@ -68882,7 +70274,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 === 167 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 168 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -68896,7 +70288,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 203 /* ObjectLiteralExpression */) { + if (container.parent.kind === 204 /* 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; @@ -68917,7 +70309,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 169 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 170 /* 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; @@ -68932,7 +70324,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 === 169 /* Constructor */; + return container.kind === 170 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -68940,23 +70332,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 === 203 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 204 /* 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 */; + return container.kind === 168 /* MethodDeclaration */ || + container.kind === 167 /* MethodSignature */ || + container.kind === 171 /* GetAccessor */ || + container.kind === 172 /* SetAccessor */ || + container.kind === 166 /* PropertyDeclaration */ || + container.kind === 169 /* ClassStaticBlockDeclaration */; } else { - 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 */; + return container.kind === 168 /* MethodDeclaration */ || + container.kind === 167 /* MethodSignature */ || + container.kind === 171 /* GetAccessor */ || + container.kind === 172 /* SetAccessor */ || + container.kind === 166 /* PropertyDeclaration */ || + container.kind === 165 /* PropertySignature */ || + container.kind === 170 /* Constructor */; } } } @@ -68964,10 +70356,10 @@ var ts; } } function getContainingObjectLiteral(func) { - 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 : + return (func.kind === 168 /* MethodDeclaration */ || + func.kind === 171 /* GetAccessor */ || + func.kind === 172 /* SetAccessor */) && func.parent.kind === 204 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 212 /* FunctionExpression */ && func.parent.kind === 294 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -68979,7 +70371,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 212 /* ArrowFunction */) { + if (func.kind === 213 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -69006,7 +70398,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 291 /* PropertyAssignment */) { + if (literal.parent.kind !== 294 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -69020,7 +70412,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 === 219 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 220 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -69073,11 +70465,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 162 /* Parameter */: + case 163 /* Parameter */: return getContextuallyTypedParameterType(declaration); - case 201 /* BindingElement */: + case 202 /* BindingElement */: return getContextualTypeForBindingElement(declaration); - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: if (ts.isStatic(declaration)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -69088,10 +70480,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 201 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); + parent.kind !== 202 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 200 /* ArrayBindingPattern */) { + if (parent.name.kind === 201 /* ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -69146,7 +70538,8 @@ var ts; // falls through to unwrap Promise for AsyncGenerators } if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function - var contextualAwaitedType = mapType(contextualReturnType, getAwaitedType); + // Get the awaited type without the `Awaited` alias + var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); } return contextualReturnType; // Regular function or Generator function @@ -69157,7 +70550,7 @@ var ts; function getContextualTypeForAwaitOperand(node, contextFlags) { var contextualType = getContextualType(node, contextFlags); if (contextualType) { - var contextualAwaitedType = getAwaitedType(contextualType); + var contextualAwaitedType = getAwaitedTypeNoAlias(contextualType); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); } return undefined; @@ -69210,6 +70603,10 @@ var ts; if (signature && !isResolvingReturnTypeOfSignature(signature)) { return getReturnTypeOfSignature(signature); } + var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl); + if (iife) { + return getContextualType(iife); + } return undefined; } // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. @@ -69219,6 +70616,11 @@ var ts; return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex); } function getContextualTypeForArgumentAtIndex(callTarget, argIndex) { + if (ts.isImportCall(callTarget)) { + return argIndex === 0 ? stringType : + argIndex === 1 ? getGlobalImportCallOptionsType(/*reportErrors*/ false) : + anyType; + } // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); @@ -69231,7 +70633,7 @@ var ts; getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 208 /* TaggedTemplateExpression */) { + if (template.parent.kind === 209 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -69444,9 +70846,9 @@ var ts; return getTypeOfPropertyOfContextualType(type, getSymbolOfNode(element).escapedName); } if (element.name) { - var nameType_1 = getLiteralTypeFromPropertyName(element.name); + var nameType_2 = 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 mapType(type, function (t) { var _a; return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType_2)) === null || _a === void 0 ? void 0 : _a.type; }, /*noReductions*/ true); } } return undefined; @@ -69520,21 +70922,21 @@ var ts; case 95 /* FalseKeyword */: case 104 /* NullKeyword */: case 79 /* Identifier */: - case 151 /* UndefinedKeyword */: + case 152 /* UndefinedKeyword */: return true; - case 204 /* PropertyAccessExpression */: - case 210 /* ParenthesizedExpression */: + case 205 /* PropertyAccessExpression */: + case 211 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 286 /* JsxExpression */: + case 287 /* 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 === 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); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 294 /* 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 === 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 discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 284 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (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 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. @@ -69614,60 +71016,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 252 /* VariableDeclaration */: - case 162 /* Parameter */: - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: - case 201 /* BindingElement */: + case 253 /* VariableDeclaration */: + case 163 /* Parameter */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 202 /* BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 212 /* ArrowFunction */: - case 245 /* ReturnStatement */: + case 213 /* ArrowFunction */: + case 246 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 216 /* AwaitExpression */: + case 217 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 206 /* CallExpression */: - if (parent.expression.kind === 100 /* ImportKeyword */) { - return stringType; - } - /* falls through */ - case 207 /* NewExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 209 /* TypeAssertionExpression */: - case 227 /* AsExpression */: + case 210 /* TypeAssertionExpression */: + case 228 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 291 /* PropertyAssignment */: - case 292 /* ShorthandPropertyAssignment */: + case 294 /* PropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 293 /* SpreadAssignment */: + case 296 /* SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 202 /* ArrayLiteralExpression */: { + case 203 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 231 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 221 /* TemplateExpression */); + case 232 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 222 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 210 /* ParenthesizedExpression */: { + case 211 /* 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); + return !tag ? getContextualType(parent, contextFlags) : + ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : + getTypeFromTypeNode(tag.typeExpression.type); } - case 228 /* NonNullExpression */: + case 229 /* NonNullExpression */: return getContextualType(parent, contextFlags); - case 286 /* JsxExpression */: + case 287 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 283 /* JsxAttribute */: - case 285 /* JsxSpreadAttribute */: + case 284 /* JsxAttribute */: + case 286 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 278 /* JsxOpeningElement */: - case 277 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: + case 278 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -69697,7 +71097,7 @@ var ts; var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType); propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== errorType) { + if (!isErrorType(intrinsicAttribs)) { propsType = intersectTypes(intrinsicAttribs, propsType); } return propsType; @@ -69790,7 +71190,7 @@ var ts; // Normal case -- add in IntrinsicClassElements and IntrinsicElements var apparentAttributesType = attributesType; var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context); - if (intrinsicClassAttribs !== errorType) { + if (!isErrorType(intrinsicClassAttribs)) { var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams @@ -69798,7 +71198,7 @@ var ts; : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== errorType) { + if (!isErrorType(intrinsicAttribs)) { apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType); } return apparentAttributesType; @@ -69906,12 +71306,9 @@ var ts; } return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } - function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 211 /* FunctionExpression */ || node.kind === 212 /* ArrowFunction */; - } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. - return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) + return ts.isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) ? getContextualSignature(node) : undefined; } @@ -69921,7 +71318,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 !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 168 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -69969,8 +71366,8 @@ var ts; return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 201 /* BindingElement */ && !!node.initializer) || - (node.kind === 219 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 202 /* BindingElement */ && !!node.initializer) || + (node.kind === 220 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -69983,7 +71380,7 @@ var ts; var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 223 /* SpreadElement */) { + if (e.kind === 224 /* SpreadElement */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); } @@ -70016,7 +71413,7 @@ var ts; elementFlags.push(4 /* Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 225 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 226 /* OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); elementFlags.push(2 /* Optional */); @@ -70051,7 +71448,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: return isNumericComputedName(name); case 79 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -70094,6 +71491,10 @@ var ts; function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { + if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */) { + return links.resolvedType = errorType; + } links.resolvedType = checkExpression(node.expression); // The computed property name of a non-static class field within a loop must be stored in a block-scoped binding. // (It needs to be bound at class evaluation time.) @@ -70164,7 +71565,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 199 /* ObjectBindingPattern */ || contextualType.pattern.kind === 203 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 200 /* ObjectBindingPattern */ || contextualType.pattern.kind === 204 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -70188,16 +71589,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 === 160 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 161 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 291 /* PropertyAssignment */ || - memberDecl.kind === 292 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 294 /* PropertyAssignment */ || + memberDecl.kind === 295 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 291 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 294 /* 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 === 292 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 295 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -70220,8 +71621,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 === 291 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 292 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 294 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 295 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -70247,7 +71648,7 @@ var ts; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } - else if (memberDecl.kind === 293 /* SpreadAssignment */) { + else if (memberDecl.kind === 296 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -70266,7 +71667,7 @@ var ts; checkSpreadPropOverrides(mergedType, allPropertiesTable, memberDecl); } offset = propertiesArray.length; - if (spread === errorType) { + if (isErrorType(spread)) { continue; } spread = getSpreadType(spread, mergedType, node.symbol, objectFlags, inConstContext); @@ -70283,7 +71684,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 === 170 /* GetAccessor */ || memberDecl.kind === 171 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 171 /* GetAccessor */ || memberDecl.kind === 172 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -70311,7 +71712,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 !== 293 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 296 /* 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)) { @@ -70323,7 +71724,7 @@ var ts; } } } - if (spread === errorType) { + if (isErrorType(spread)) { return errorType; } if (spread !== emptyObjectType) { @@ -70462,7 +71863,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 285 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 286 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -70488,7 +71889,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 276 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 277 /* 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); @@ -70545,7 +71946,7 @@ var ts; childrenTypes.push(stringType); } } - else if (child.kind === 286 /* JsxExpression */ && !child.expression) { + else if (child.kind === 287 /* JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -70590,7 +71991,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node); - if (intrinsicElementsType !== errorType) { + if (!isErrorType(intrinsicElementsType)) { // Property case if (!ts.isIdentifier(node.tagName)) return ts.Debug.fail(); @@ -70753,7 +72154,7 @@ var ts; // var CustomTag: "h1" = "h1"; // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location); - if (intrinsicElementsType !== errorType) { + if (!isErrorType(intrinsicElementsType)) { var stringLiteralTypeName = type.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -70821,7 +72222,7 @@ var ts; } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); - if (type === errorType) + if (isErrorType(type)) return undefined; return type; } @@ -70878,6 +72279,14 @@ var ts; markAliasSymbolAsReferenced(jsxFactorySym); } } + // For JsxFragment, mark jsx pragma as referenced via resolveName + if (ts.isJsxOpeningFragment(node)) { + var file = ts.getSourceFileOfNode(node); + var localJsxNamespace = getLocalJsxNamespace(file); + if (localJsxNamespace) { + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + } + } } if (isNodeOpeningLikeElement) { var jsxOpeningLikeNode = node; @@ -70968,10 +72377,24 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } + var errorNode = !reportError ? undefined : + node.kind === 160 /* QualifiedName */ ? node.right : + node.kind === 199 /* ImportType */ ? node : + node.kind === 202 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); + } + /** + * Check whether the requested property can be accessed at the requested location. + * Returns true if node is a valid property access, and false otherwise. + * @param location The location node where we want to check if the property is accessible. + * @param isSuper True if the access is from `super.`. + * @param writing True if this is a write property access, false if it is a read property access. + * @param containingType The type of the object whose property is being accessed. (Not the type of the property.) + * @param prop The symbol for the property being accessed. + * @param errorNode The node where we should report an invalid property access error, or undefined if we should not report errors. + */ + function checkPropertyAccessibilityAtLocation(location, isSuper, writing, containingType, prop, errorNode) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop, writing); - 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 @@ -70982,7 +72405,7 @@ var ts; // a super property access is permitted and must specify a public static member function of the base class. if (languageVersion < 2 /* ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { - if (reportError) { + if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } return false; @@ -70993,7 +72416,7 @@ var ts; // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an // additional error elsewhere. - if (reportError) { + if (errorNode) { error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); } return false; @@ -71001,11 +72424,11 @@ var ts; } // Referencing abstract properties within their own constructors is not allowed if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && - (ts.isThisProperty(node) || ts.isThisInitializedObjectBindingExpression(node) || ts.isObjectBindingPattern(node.parent) && ts.isThisInitializedDeclaration(node.parent.parent))) { + (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); - if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) { - if (reportError) { - error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); // TODO: GH#18217 + if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); } return false; } @@ -71018,8 +72441,8 @@ var ts; // Private property is accessible if the property is within the declaring class if (flags & 8 /* Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); - if (!isNodeWithinClass(node, declaringClassDeclaration)) { - if (reportError) { + if (!isNodeWithinClass(location, declaringClassDeclaration)) { + if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); } return false; @@ -71033,7 +72456,7 @@ var ts; } // Find the first enclosing class that has the declaring classes of the protected constituents // of the property as base classes - var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { + var enclosingClass = forEachEnclosingClass(location, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined; }); @@ -71042,9 +72465,9 @@ var ts; // allow PropertyAccessibility if context is in function with this parameter // static member access is disallow var thisParameter = void 0; - if (flags & 32 /* Static */ || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) { - if (reportError) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type)); + if (flags & 32 /* Static */ || !(thisParameter = getThisParameterFromNodeContext(location)) || !thisParameter.type) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } return false; } @@ -71055,13 +72478,13 @@ var ts; if (flags & 32 /* Static */) { return true; } - if (type.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type - type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined + containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } - if (!type || !hasBaseType(type, enclosingClass)) { - if (reportError) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2, symbolToString(prop), typeToString(enclosingClass), typeToString(type)); + if (!containingType || !hasBaseType(containingType, enclosingClass)) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2, symbolToString(prop), typeToString(enclosingClass), typeToString(containingType)); } return false; } @@ -71113,7 +72536,7 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType !== errorType && nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; @@ -71132,7 +72555,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 210 /* ParenthesizedExpression */) { + while (node.parent.kind === 211 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -71148,6 +72571,36 @@ var ts; } } } + function checkGrammarPrivateIdentifierExpression(privId) { + if (!ts.getContainingClass(privId)) { + return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + } + if (!ts.isExpressionNode(privId)) { + return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); + } + if (!getSymbolForPrivateIdentifierExpression(privId)) { + return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); + } + return false; + } + function checkPrivateIdentifierExpression(privId) { + checkGrammarPrivateIdentifierExpression(privId); + var symbol = getSymbolForPrivateIdentifierExpression(privId); + if (symbol) { + markPropertyAsReferenced(symbol, /* nodeForCheckWriteOnly: */ undefined, /* isThisAccess: */ false); + } + return anyType; + } + function getSymbolForPrivateIdentifierExpression(privId) { + if (!ts.isExpressionNode(privId)) { + return undefined; + } + var links = getNodeLinks(privId); + if (links.resolvedSymbol === undefined) { + links.resolvedSymbol = lookupSymbolForPrivateIdentifierDeclaration(privId.escapedText, privId); + } + return links.resolvedSymbol; + } function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) { return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName); } @@ -71211,7 +72664,7 @@ var ts; if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) { grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right)); } - if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (compilerOptions.target === 99 /* ESNext */ && !useDefineForClassFields)) { + if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) { var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration); var parentStaticFieldInitializer = ts.findAncestor(node, function (n) { if (n === lexicalClass_1) @@ -71230,7 +72683,7 @@ var ts; } if (isAnyLike) { if (lexicallyScopedSymbol) { - return apparentType; + return isErrorType(apparentType) ? errorType : apparentType; } if (!ts.getContainingClass(right)) { grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); @@ -71254,7 +72707,8 @@ var ts; if (ts.isIdentifier(left) && parentSymbol) { markAliasReferenced(parentSymbol, node); } - return apparentType; + return isErrorType(apparentType) ? errorType : apparentType; + ; } prop = getPropertyOfType(apparentType, right.escapedText); } @@ -71360,7 +72814,7 @@ var ts; 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 */)) { + if (flowContainer.kind === 170 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { assumeUninitialized = true; } } @@ -71394,8 +72848,8 @@ var ts; && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 255 /* ClassDeclaration */ && - node.parent.kind !== 176 /* TypeReference */ && + else if (valueDeclaration.kind === 256 /* ClassDeclaration */ && + node.parent.kind !== 177 /* TypeReference */ && !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -71407,25 +72861,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return true; - 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 */: + case 294 /* PropertyAssignment */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 296 /* SpreadAssignment */: + case 161 /* ComputedPropertyName */: + case 232 /* TemplateSpan */: + case 287 /* JsxExpression */: + case 284 /* JsxAttribute */: + case 285 /* JsxAttributes */: + case 286 /* JsxSpreadAttribute */: + case 279 /* JsxOpeningElement */: + case 227 /* ExpressionWithTypeArguments */: + case 290 /* HeritageClause */: return false; - case 212 /* ArrowFunction */: - case 236 /* ExpressionStatement */: + case 213 /* ArrowFunction */: + case 237 /* ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -71510,7 +72964,7 @@ var ts; if (relatedInfo) { ts.addRelatedInfo(resultDiagnostic, relatedInfo); } - addErrorOrSuggestion(!isUncheckedJS, resultDiagnostic); + addErrorOrSuggestion(!isUncheckedJS || errorInfo.code !== ts.Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code, resultDiagnostic); } function containerSeemsToBeEmptyDomElement(containingType) { return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) && @@ -71583,7 +73037,19 @@ var ts; // Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function // So the table *contains* `x` but `x` isn't actually in scope. // However, resolveNameHelper will continue and call this callback again, so we'll eventually get a correct suggestion. - return symbol || getSpellingSuggestionForName(ts.unescapeLeadingUnderscores(name), ts.arrayFrom(symbols.values()), meaning); + if (symbol) + return symbol; + var candidates; + if (symbols === globals) { + var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) + ? createSymbol(524288 /* TypeAlias */, s) + : undefined; }); + candidates = primitives.concat(ts.arrayFrom(symbols.values())); + } + else { + candidates = ts.arrayFrom(symbols.values()); + } + return getSpellingSuggestionForName(ts.unescapeLeadingUnderscores(name), candidates, meaning); }); return result; } @@ -71622,6 +73088,10 @@ var ts; } return suggestion; } + function getSuggestedTypeForNonexistentStringLiteralType(source, target) { + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); + } /** * Given a name and a list of symbols whose names are *not* equal to the name, return a spelling suggestion if there is one that is close enough. * Names less than length 3 only check for case-insensitive equality, not levenshtein distance. @@ -71684,39 +73154,66 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 198 /* ImportType */: + case 199 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } + /** + * Checks if an existing property access is valid for completions purposes. + * @param node a property access-like node where we want to check if we can access a property. + * This node does not need to be an access of the property we are checking. + * e.g. in completions, this node will often be an incomplete property access node, as in `foo.`. + * Besides providing a location (i.e. scope) used to check property accessibility, we use this node for + * computing whether this is a `super` property access. + * @param type the type whose property we are checking. + * @param property the accessed property's symbol. + */ function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 204 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, property.escapedName, type); + return isPropertyAccessible(node, node.kind === 205 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { - if (type === errorType || isTypeAny(type)) { + // Short-circuiting for improved performance. + if (isTypeAny(type)) { return true; } var prop = getPropertyOfType(type, propertyName); - if (prop) { - if (prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)) { - var declClass_1 = ts.getContainingClass(prop.valueDeclaration); - return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; }); - } - return checkPropertyAccessibility(node, isSuper, /*writing*/ false, type, prop, /* reportError */ false); + return !!prop && isPropertyAccessible(node, isSuper, /* isWrite */ false, type, prop); + } + /** + * Checks if a property can be accessed in a location. + * The location is given by the `node` parameter. + * The node does not need to be a property access. + * @param node location where to check property accessibility + * @param isSuper whether to consider this a `super` property access, e.g. `super.foo`. + * @param isWrite whether this is a write access, e.g. `++foo.x`. + * @param containingType type where the property comes from. + * @param property property symbol. + */ + function isPropertyAccessible(node, isSuper, isWrite, containingType, property) { + // Short-circuiting for improved performance. + if (isTypeAny(containingType)) { + return true; } - // In js files properties of unions are allowed in completion - return ts.isInJSFile(node) && (type.flags & 1048576 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); }); + // A #private property access in an optional chain is an error dealt with by the parser. + // The checker does not check for it, so we need to do our own check here. + if (property.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(property.valueDeclaration)) { + var declClass_1 = ts.getContainingClass(property.valueDeclaration); + return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; }); + } + return checkPropertyAccessibilityAtLocation(node, isSuper, isWrite, containingType, property); } /** * Return the symbol of the for-in variable declared or referenced by the given for-in statement. */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 253 /* VariableDeclarationList */) { + if (initializer.kind === 254 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -71745,7 +73242,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 241 /* ForInStatement */ && + if (node.kind === 242 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -71771,7 +73268,7 @@ var ts; var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); - if (objectType === errorType || objectType === silentNeverType) { + if (isErrorType(objectType) || objectType === silentNeverType) { return objectType; } if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { @@ -71794,13 +73291,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 208 /* TaggedTemplateExpression */) { + if (node.kind === 209 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 163 /* Decorator */) { + else if (node.kind !== 164 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -71864,7 +73361,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 223 /* SpreadElement */ || arg.kind === 230 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 224 /* SpreadElement */ || arg.kind === 231 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -71881,9 +73378,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 === 208 /* TaggedTemplateExpression */) { + if (node.kind === 209 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 221 /* TemplateExpression */) { + if (node.template.kind === 222 /* 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. @@ -71898,7 +73395,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 163 /* Decorator */) { + else if (node.kind === 164 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -71912,7 +73409,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 207 /* NewExpression */); + ts.Debug.assert(node.kind === 208 /* NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -72015,7 +73512,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 !== 163 /* Decorator */) { + if (node.kind !== 164 /* 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 @@ -72063,7 +73560,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 225 /* OmittedExpression */) { + if (arg.kind !== 226 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -72087,7 +73584,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 === 230 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 231 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -72097,13 +73594,13 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 230 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 231 /* 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 === 223 /* SpreadElement */ ? arg.expression : arg)); + types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 224 /* SpreadElement */ ? arg.expression : arg)); flags.push(4 /* Rest */); } } @@ -72114,7 +73611,7 @@ var ts; types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); flags.push(1 /* Required */); } - if (arg.kind === 230 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 231 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -72258,7 +73755,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 207 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 208 /* 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. @@ -72276,7 +73773,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 !== 225 /* OmittedExpression */) { + if (arg.kind !== 226 /* 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), @@ -72321,8 +73818,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 206 /* CallExpression */ ? node.expression : - node.kind === 208 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 207 /* CallExpression */ ? node.expression : + node.kind === 209 /* TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -72340,17 +73837,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 208 /* TaggedTemplateExpression */) { + if (node.kind === 209 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 221 /* TemplateExpression */) { + if (template.kind === 222 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 163 /* Decorator */) { + if (node.kind === 164 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -72364,7 +73861,7 @@ var ts; 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 === 223 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 224 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; @@ -72391,30 +73888,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* 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 162 /* Parameter */: + case 163 /* 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 === 169 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 170 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 165 /* PropertyDeclaration */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 166 /* PropertyDeclaration */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* 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 !== 165 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 166 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -72428,17 +73925,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: return 1; - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return 2; - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* 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 162 /* Parameter */: + case 163 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -72474,7 +73971,7 @@ var ts; return false; var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; - if (!decl || !ts.isParameter(decl) || !isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { + if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; } var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); @@ -72574,8 +74071,8 @@ 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 === 208 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 163 /* Decorator */; + var isTaggedTemplate = node.kind === 209 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 164 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray && produceDiagnostics; var typeArguments; @@ -72637,7 +74134,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 === 206 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 207 /* 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 @@ -72965,7 +74462,7 @@ var ts; } return anySignature; } - if (superType !== errorType) { + if (!isErrorType(superType)) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); @@ -72993,7 +74490,7 @@ var ts; return silentNeverSignature; } var apparentType = getApparentType(funcType); - if (apparentType === errorType) { + if (isErrorType(apparentType)) { // Another error has already been reported return resolveErrorCall(node); } @@ -73009,7 +74506,7 @@ var ts; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { // The unknownType indicates that an error already occurred (and was reported). No // need to report another error in this case. - if (funcType !== errorType && node.typeArguments) { + if (!isErrorType(funcType) && node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); } return resolveUntypedCall(node); @@ -73086,7 +74583,7 @@ var ts; // signatures for overload resolution. The result type of the function call becomes // the result type of the operation. expressionType = getApparentType(expressionType); - if (expressionType === errorType) { + if (isErrorType(expressionType)) { // Another error has already been reported return resolveErrorCall(node); } @@ -73182,7 +74679,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 !== 169 /* Constructor */) { + if (!modifiers || declaration.kind !== 170 /* Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -73301,7 +74798,7 @@ var ts; function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) { var tagType = checkExpression(node.tag); var apparentType = getApparentType(tagType); - if (apparentType === errorType) { + if (isErrorType(apparentType)) { // Another error has already been reported return resolveErrorCall(node); } @@ -73326,16 +74823,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 162 /* Parameter */: + case 163 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -73347,7 +74844,7 @@ var ts; function resolveDecorator(node, candidatesOutArray, checkMode) { var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); - if (apparentType === errorType) { + if (isErrorType(apparentType)) { return resolveErrorCall(node); } var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); @@ -73381,7 +74878,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(129 /* 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(130 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, @@ -73402,7 +74899,7 @@ var ts; } var exprTypes = checkExpression(node.tagName); var apparentType = getApparentType(exprTypes); - if (apparentType === errorType) { + if (isErrorType(apparentType)) { return resolveErrorCall(node); } var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node); @@ -73430,16 +74927,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 206 /* CallExpression */: + case 207 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 207 /* NewExpression */: + case 208 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 163 /* Decorator */: + case 164 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 278 /* JsxOpeningElement */: - case 277 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: + case 278 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -73571,7 +75068,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 204 /* PropertyAccessExpression */) { + while (parent && parent.kind === 205 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { @@ -73598,12 +75095,12 @@ var ts; if (node.expression.kind === 106 /* SuperKeyword */) { return voidType; } - if (node.kind === 207 /* NewExpression */) { + if (node.kind === 208 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 169 /* Constructor */ && - declaration.kind !== 173 /* ConstructSignature */ && - declaration.kind !== 178 /* ConstructorType */ && + declaration.kind !== 170 /* Constructor */ && + declaration.kind !== 174 /* ConstructSignature */ && + declaration.kind !== 179 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -73623,7 +75120,7 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 206 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 236 /* ExpressionStatement */ && + if (node.kind === 207 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 237 /* 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); @@ -73653,20 +75150,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 206 /* CallExpression */: - case 163 /* Decorator */: - case 207 /* NewExpression */: + case 207 /* CallExpression */: + case 164 /* Decorator */: + case 208 /* NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 278 /* JsxOpeningElement */: - case 277 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: + case 278 /* JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: return node.argumentExpression; - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return node.name; - case 176 /* TypeReference */: + case 177 /* TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -73699,39 +75196,62 @@ var ts; } var specifier = node.arguments[0]; var specifierType = checkExpressionCached(specifier); + var optionsType = node.arguments.length > 1 ? checkExpressionCached(node.arguments[1]) : undefined; // Even though multiple arguments is grammatically incorrect, type-check extra arguments for completion - for (var i = 1; i < node.arguments.length; ++i) { + for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } + if (optionsType) { + var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); + if (importCallOptionsType !== emptyObjectType) { + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + } + } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { - return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); + return createPromiseReturnType(node, getTypeWithSyntheticDefaultOnly(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier) || + getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier)); } } return createPromiseReturnType(node, anyType); } - function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { + function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { + var memberTable = ts.createSymbolTable(); + var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + newSymbol.parent = originalSymbol; + newSymbol.nameType = getStringLiteralType("default"); + newSymbol.target = resolveSymbol(symbol); + memberTable.set("default" /* Default */, newSymbol); + return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); + } + function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { + var hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier); + if (hasDefaultOnly && type && !isErrorType(type)) { + var synthType = type; + if (!synthType.defaultOnlyType) { + var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol); + synthType.defaultOnlyType = type_4; + } + return synthType.defaultOnlyType; + } + return undefined; + } + function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) { var _a; - if (allowSyntheticDefaultImports && type && type !== errorType) { + if (allowSyntheticDefaultImports && type && !isErrorType(type)) { var synthType = type; if (!synthType.syntheticType) { var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); - var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false); + var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); - newSymbol.parent = originalSymbol; - 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, ts.emptyArray); + var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; } @@ -73759,9 +75279,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 254 /* FunctionDeclaration */ + ? 255 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 252 /* VariableDeclaration */ + ? 253 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -73781,6 +75301,12 @@ var ts; return getReturnTypeOfSignature(signature); } function checkAssertion(node) { + if (node.kind === 210 /* TypeAssertionExpression */) { + var file = ts.getSourceFileOfNode(node); + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); + } + } return checkAssertionWorker(node, node.type, node.expression); } function isValidConstAssertionArgument(node) { @@ -73791,27 +75317,25 @@ var ts; case 9 /* BigIntLiteral */: case 110 /* TrueKeyword */: case 95 /* FalseKeyword */: - case 202 /* ArrayLiteralExpression */: - case 203 /* ObjectLiteralExpression */: - case 221 /* TemplateExpression */: + case 203 /* ArrayLiteralExpression */: + case 204 /* ObjectLiteralExpression */: + case 222 /* TemplateExpression */: return true; - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 217 /* PrefixUnaryExpression */: + case 218 /* 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 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: var expr = node.expression; - if (ts.isIdentifier(expr)) { - var symbol = getSymbolAtLocation(expr); - if (symbol && symbol.flags & 2097152 /* Alias */) { - symbol = resolveAlias(symbol); - } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + var symbol = getTypeOfNode(expr).symbol; + if (symbol && symbol.flags & 2097152 /* Alias */) { + symbol = resolveAlias(symbol); } + return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); } return false; } @@ -73826,7 +75350,7 @@ var ts; checkSourceElement(type); exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType)); var targetType = getTypeFromTypeNode(type); - if (produceDiagnostics && targetType !== errorType) { + if (produceDiagnostics && !isErrorType(targetType)) { var widenedType = getWidenedType(exprType); if (!isTypeComparableTo(targetType, widenedType)) { checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first); @@ -73859,7 +75383,7 @@ var ts; return getGlobalImportMetaExpressionType(); case 103 /* NewKeyword */: var type = checkNewTargetMetaProperty(node); - return type === errorType ? errorType : createNewTargetExpressionType(type); + return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: ts.Debug.assertNever(node.keywordToken); } @@ -73870,7 +75394,7 @@ var ts; 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 === 169 /* Constructor */) { + else if (container.kind === 170 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -73880,8 +75404,13 @@ var ts; } } function checkImportMetaProperty(node) { - if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) { - error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system); + if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) { + if (ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.ESNext) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output); + } + } + else if (moduleKind < ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.System) { + error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext); } var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); @@ -73945,7 +75474,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 195 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 196 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -74187,7 +75716,8 @@ var ts; var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type - promisedType = getAwaitedType(promisedType) || unknownType; + // Unwrap an `Awaited` to `T` to improve inference. + promisedType = getAwaitedTypeNoAlias(unwrapAwaitedType(promisedType)) || unknownType; return createTypeReference(globalPromiseType, [promisedType]); } return unknownType; @@ -74197,7 +75727,8 @@ var ts; var globalPromiseLikeType = getGlobalPromiseLikeType(/*reportErrors*/ true); if (globalPromiseLikeType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type - promisedType = getAwaitedType(promisedType) || unknownType; + // Unwrap an `Awaited` to `T` to improve inference. + promisedType = getAwaitedTypeNoAlias(unwrapAwaitedType(promisedType)) || unknownType; return createTypeReference(globalPromiseLikeType, [promisedType]); } return unknownType; @@ -74238,14 +75769,14 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 233 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 234 /* 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 // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which we will wrap in // the native Promise type later in this function. - returnType = checkAwaitedType(returnType, /*errorNode*/ func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + returnType = unwrapAwaitedType(checkAwaitedType(returnType, /*withAlias*/ false, /*errorNode*/ func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } } else if (isGenerator) { // Generator or AsyncGenerator function @@ -74423,17 +75954,17 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 214 /* TypeOfExpression */) { + if (node.expression.kind === 215 /* 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. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); - var type_4 = getBaseConstraintOfType(operandType) || operandType; + var type_5 = getBaseConstraintOfType(operandType) || operandType; // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types. - if (type_4.flags & 3 /* AnyOrUnknown */) { + if (type_5.flags & 3 /* AnyOrUnknown */) { return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */; } - return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); + return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */); } var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { @@ -74463,7 +75994,7 @@ var ts; // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. - type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } if (type.flags & 131072 /* Never */) { hasReturnOfTypeNever = true; @@ -74486,11 +76017,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return true; - case 167 /* MethodDeclaration */: - return func.parent.kind === 203 /* ObjectLiteralExpression */; + case 168 /* MethodDeclaration */: + return func.parent.kind === 204 /* ObjectLiteralExpression */; default: return false; } @@ -74516,7 +76047,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 === 166 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 233 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 167 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 234 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; @@ -74549,7 +76080,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 168 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); @@ -74576,7 +76107,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 211 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 212 /* FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -74622,7 +76153,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 167 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 168 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -74635,7 +76166,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 233 /* Block */) { + if (node.body.kind === 234 /* Block */) { checkSourceElement(node.body); } else { @@ -74648,7 +76179,7 @@ var ts; var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function - var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } else { // Normal function @@ -74725,7 +76256,7 @@ var ts; 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 === 169 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 170 /* Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -74750,7 +76281,7 @@ var ts; var symbol_2 = getNodeLinks(node).resolvedSymbol; if (symbol_2.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 266 /* NamespaceImport */; + return !!declaration && declaration.kind === 267 /* NamespaceImport */; } } } @@ -74823,9 +76354,9 @@ var ts; var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_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); diagnostics.add(diagnostic); } - if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) { + if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); - var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher); + var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher); diagnostics.add(diagnostic); } } @@ -74836,7 +76367,7 @@ 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); - if (container && container.kind !== 169 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 170 /* 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); } @@ -74849,8 +76380,8 @@ var ts; } } var operandType = checkExpression(node.expression); - var awaitedType = checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3 /* AnyOrUnknown */)) { + var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -74999,11 +76530,29 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - leftType = checkNonNullType(leftType, left); + if (ts.isPrivateIdentifier(left)) { + if (languageVersion < 99 /* ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + } + // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type + // which provides us with the opportunity to emit more detailed errors + if (!getNodeLinks(left).resolvedSymbol && ts.getContainingClass(left)) { + var isUncheckedJS = isUncheckedJSSuggestion(left, rightType.symbol, /*excludeClasses*/ true); + reportNonexistentProperty(left, rightType, isUncheckedJS); + } + } + else { + leftType = checkNonNullType(leftType, left); + // TypeScript 1.0 spec (April 2014): 4.15.5 + // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. + if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); + } + } rightType = checkNonNullType(rightType, right); // TypeScript 1.0 spec (April 2014): 4.15.5 - // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, - // and the right operand to be + // The in operator requires the right operand to be // // 1. assignable to the non-primitive type, // 2. an unconstrained type parameter, @@ -75021,10 +76570,6 @@ var ts; // unless *all* instantiations would result in an error. // // The result is always of the Boolean primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { - error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); - } var rightTypeConstraint = getConstraintOfType(rightType); if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || @@ -75048,7 +76593,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 291 /* PropertyAssignment */ || property.kind === 292 /* ShorthandPropertyAssignment */) { + if (property.kind === 294 /* PropertyAssignment */ || property.kind === 295 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -75061,9 +76606,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 292 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 295 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 293 /* SpreadAssignment */) { + else if (property.kind === 296 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -75101,7 +76646,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 === 223 /* SpreadElement */) { + if (node.elements[i].kind === 224 /* SpreadElement */) { type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); @@ -75111,8 +76656,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 225 /* OmittedExpression */) { - if (element.kind !== 223 /* SpreadElement */) { + if (element.kind !== 226 /* OmittedExpression */) { + if (element.kind !== 224 /* SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -75130,7 +76675,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 219 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 220 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -75146,7 +76691,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 292 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 295 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -75162,24 +76707,24 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 219 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 220 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 203 /* ObjectLiteralExpression */) { + if (target.kind === 204 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 202 /* ArrayLiteralExpression */) { + if (target.kind === 203 /* 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 === 293 /* SpreadAssignment */ ? + var error = target.parent.kind === 296 /* 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 === 293 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 296 /* 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)) { @@ -75204,36 +76749,36 @@ var ts; case 79 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 208 /* TaggedTemplateExpression */: - case 221 /* TemplateExpression */: + case 209 /* TaggedTemplateExpression */: + case 222 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: 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 */: + case 152 /* UndefinedKeyword */: + case 212 /* FunctionExpression */: + case 225 /* ClassExpression */: + case 213 /* ArrowFunction */: + case 203 /* ArrayLiteralExpression */: + case 204 /* ObjectLiteralExpression */: + case 215 /* TypeOfExpression */: + case 229 /* NonNullExpression */: + case 278 /* JsxSelfClosingElement */: + case 277 /* JsxElement */: return true; - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 217 /* PrefixUnaryExpression */: - case 218 /* PostfixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -75245,9 +76790,9 @@ var ts; } return false; // Some forms listed here for clarity - 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 + case 216 /* VoidExpression */: // Explicit opt-out + case 210 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 228 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -75284,7 +76829,7 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 203 /* ObjectLiteralExpression */ || node.left.kind === 202 /* ArrayLiteralExpression */)) { + if (operator === 63 /* EqualsToken */ && (node.left.kind === 204 /* ObjectLiteralExpression */ || node.left.kind === 203 /* ArrayLiteralExpression */)) { state.skip = true; setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); return state; @@ -75377,7 +76922,7 @@ 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 === 63 /* EqualsToken */ && (left.kind === 203 /* ObjectLiteralExpression */ || left.kind === 202 /* ArrayLiteralExpression */)) { + if (operator === 63 /* EqualsToken */ && (left.kind === 204 /* ObjectLiteralExpression */ || left.kind === 203 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); } var leftType; @@ -75491,7 +77036,7 @@ var ts; else if (isTypeAny(leftType) || isTypeAny(rightType)) { // Otherwise, the result is of type Any. // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. - resultType = leftType === errorType || rightType === errorType ? errorType : anyType; + resultType = isErrorType(leftType) || isErrorType(rightType) ? errorType : anyType; } // Symbols are not allowed at all in arithmetic expressions if (resultType && !checkForDisallowedESSymbolOperand(operator)) { @@ -75659,8 +77204,15 @@ var ts; // and the type of the non-compound operation to be assignable to the type of VarExpr. if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { + var headMessage = void 0; + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); + if (isExactOptionalPropertyMismatch(valueType, target)) { + headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; + } + } // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported - checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); + checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right, headMessage); } } } @@ -75697,8 +77249,8 @@ var ts; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; if (isRelated) { - var awaitedLeftType = getAwaitedType(leftType); - var awaitedRightType = getAwaitedType(rightType); + var awaitedLeftType = getAwaitedTypeNoAlias(leftType); + var awaitedRightType = getAwaitedTypeNoAlias(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) && isRelated(awaitedLeftType, awaitedRightType); @@ -75836,7 +77388,7 @@ var ts; type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); } function getContextNode(node) { - if (node.kind === 284 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 285 /* 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; @@ -75884,14 +77436,16 @@ var ts; return links.resolvedType; } function isTypeAssertion(node) { - node = ts.skipParentheses(node); - return node.kind === 209 /* TypeAssertionExpression */ || node.kind === 227 /* AsExpression */; + node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); + return node.kind === 210 /* TypeAssertionExpression */ || + node.kind === 228 /* AsExpression */ || + ts.isJSDocTypeAssertion(node); } 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 === 200 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 201 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -75901,7 +77455,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 === 201 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 202 /* 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)) { @@ -75955,6 +77509,7 @@ var ts; function isConstContext(node) { var parent = node.parent; return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) || + ts.isJSDocTypeAssertion(parent) && ts.isConstTypeReference(ts.getJSDocTypeAssertionType(parent)) || (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) || (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent) || ts.isTemplateSpan(parent)) && isConstContext(parent.parent); } @@ -75968,7 +77523,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 === 160 /* ComputedPropertyName */) { + if (node.name.kind === 161 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -75979,7 +77534,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 === 160 /* ComputedPropertyName */) { + if (node.name.kind === 161 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -76152,7 +77707,14 @@ var ts; return type; } function getQuickTypeOfExpression(node) { - var expr = ts.skipParentheses(node); + var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); + if (ts.isJSDocTypeAssertion(expr)) { + var type = ts.getJSDocTypeAssertionType(expr); + if (!ts.isConstTypeReference(type)) { + return getTypeFromTypeNode(type); + } + } + 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 !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { @@ -76215,11 +77777,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - 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 + var ok = (node.parent.kind === 205 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 206 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* Identifier */ || node.kind === 160 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 180 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 274 /* 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); } @@ -76232,9 +77794,9 @@ var ts; } } function checkParenthesizedExpression(node, checkMode) { - var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined; - if (tag) { - return checkAssertionWorker(tag.typeExpression.type, tag.typeExpression.type, node.expression, checkMode); + if (ts.hasJSDocNodes(node) && ts.isJSDocTypeAssertion(node)) { + var type = ts.getJSDocTypeAssertionType(node); + return checkAssertionWorker(type, type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -76244,15 +77806,17 @@ 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 224 /* ClassExpression */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 225 /* ClassExpression */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { case 79 /* Identifier */: return checkIdentifier(node, checkMode); + case 80 /* PrivateIdentifier */: + return checkPrivateIdentifierExpression(node); case 108 /* ThisKeyword */: return checkThisExpression(node); case 106 /* SuperKeyword */: @@ -76275,78 +77839,78 @@ var ts; return trueType; case 95 /* FalseKeyword */: return falseType; - case 221 /* TemplateExpression */: + case 222 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: return checkQualifiedName(node, checkMode); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 206 /* CallExpression */: + case 207 /* CallExpression */: if (node.expression.kind === 100 /* ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 207 /* NewExpression */: + case 208 /* NewExpression */: return checkCallExpression(node, checkMode); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 224 /* ClassExpression */: + case 225 /* ClassExpression */: return checkClassExpression(node); - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 214 /* TypeOfExpression */: + case 215 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 209 /* TypeAssertionExpression */: - case 227 /* AsExpression */: + case 210 /* TypeAssertionExpression */: + case 228 /* AsExpression */: return checkAssertion(node); - case 228 /* NonNullExpression */: + case 229 /* NonNullExpression */: return checkNonNullAssertion(node); - case 229 /* MetaProperty */: + case 230 /* MetaProperty */: return checkMetaProperty(node); - case 213 /* DeleteExpression */: + case 214 /* DeleteExpression */: return checkDeleteExpression(node); - case 215 /* VoidExpression */: + case 216 /* VoidExpression */: return checkVoidExpression(node); - case 216 /* AwaitExpression */: + case 217 /* AwaitExpression */: return checkAwaitExpression(node); - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 218 /* PostfixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 223 /* SpreadElement */: + case 224 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 225 /* OmittedExpression */: + case 226 /* OmittedExpression */: return undefinedWideningType; - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: return checkYieldExpression(node); - case 230 /* SyntheticExpression */: + case 231 /* SyntheticExpression */: return checkSyntheticExpression(node); - case 286 /* JsxExpression */: + case 287 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 276 /* JsxElement */: + case 277 /* JsxElement */: return checkJsxElement(node, checkMode); - case 277 /* JsxSelfClosingElement */: + case 278 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 280 /* JsxFragment */: + case 281 /* JsxFragment */: return checkJsxFragment(node); - case 284 /* JsxAttributes */: + case 285 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 278 /* JsxOpeningElement */: + case 279 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -76383,10 +77947,10 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 169 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 170 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 169 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 170 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -76397,13 +77961,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 === 169 /* Constructor */ || func.kind === 173 /* ConstructSignature */ || func.kind === 178 /* ConstructorType */) { + if (func.kind === 170 /* Constructor */ || func.kind === 174 /* ConstructSignature */ || func.kind === 179 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 212 /* ArrowFunction */) { + if (func.kind === 213 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 170 /* GetAccessor */ || func.kind === 171 /* SetAccessor */) { + if (func.kind === 171 /* GetAccessor */ || func.kind === 172 /* SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -76461,13 +78025,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 212 /* ArrowFunction */: - case 172 /* CallSignature */: - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 177 /* FunctionType */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 213 /* ArrowFunction */: + case 173 /* CallSignature */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 178 /* FunctionType */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -76485,7 +78049,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 200 /* ArrayBindingPattern */ || name.kind === 199 /* ObjectBindingPattern */) { + else if (name.kind === 201 /* ArrayBindingPattern */ || name.kind === 200 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -76494,13 +78058,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 174 /* IndexSignature */) { + if (node.kind === 175 /* 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 === 177 /* FunctionType */ || node.kind === 254 /* FunctionDeclaration */ || node.kind === 178 /* ConstructorType */ || - node.kind === 172 /* CallSignature */ || node.kind === 169 /* Constructor */ || - node.kind === 173 /* ConstructSignature */) { + else if (node.kind === 178 /* FunctionType */ || node.kind === 255 /* FunctionDeclaration */ || node.kind === 179 /* ConstructorType */ || + node.kind === 173 /* CallSignature */ || node.kind === 170 /* Constructor */ || + node.kind === 174 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -76519,7 +78083,7 @@ var ts; checkExternalEmitHelpers(node, 128 /* Generator */); } } - checkTypeParameters(node.typeParameters); + checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); ts.forEach(node.parameters, checkParameter); // TODO(rbuckton): Should we start checking JSDoc types? if (node.type) { @@ -76530,10 +78094,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 173 /* ConstructSignature */: + case 174 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 172 /* CallSignature */: + case 173 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -76563,7 +78127,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 174 /* IndexSignature */ && node.kind !== 312 /* JSDocFunctionType */) { + if (node.kind !== 175 /* IndexSignature */ && node.kind !== 315 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -76575,7 +78139,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 === 169 /* Constructor */) { + if (member.kind === 170 /* 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)) { @@ -76597,16 +78161,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 170 /* GetAccessor */: + case 171 /* GetAccessor */: addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); break; - case 171 /* SetAccessor */: + case 172 /* SetAccessor */: addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); break; - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); break; - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); break; } @@ -76678,7 +78242,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 === 164 /* PropertySignature */) { + if (member.kind === 165 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -76703,7 +78267,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 256 /* InterfaceDeclaration */) { + if (node.kind === 257 /* 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 @@ -76754,7 +78318,7 @@ var ts; 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) { + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -76771,7 +78335,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 168 /* 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 @@ -76825,7 +78389,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 165 /* PropertyDeclaration */ && + return n.kind === 166 /* PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -76846,7 +78410,7 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeFirst = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); // Skip past any prologue directives to find the first statement @@ -76856,7 +78420,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 === 236 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 237 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -76881,7 +78445,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 170 /* GetAccessor */) { + if (node.kind === 171 /* 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); @@ -76891,15 +78455,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 === 160 /* ComputedPropertyName */) { + if (node.name.kind === 161 /* 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, 170 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 171 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 171 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 172 /* SetAccessor */); if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { getNodeLinks(getter).flags |= 1 /* TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); @@ -76921,7 +78485,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 170 /* GetAccessor */) { + if (node.kind === 171 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -76952,7 +78516,7 @@ var ts; } function getTypeParametersForTypeReference(node) { var type = getTypeFromTypeReference(node); - if (type !== errorType) { + if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || @@ -76963,12 +78527,12 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 176 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 177 /* 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); var type = getTypeFromTypeReference(node); - if (type !== errorType) { + if (!isErrorType(type)) { if (node.typeArguments && produceDiagnostics) { var typeParameters = getTypeParametersForTypeReference(node); if (typeParameters) { @@ -76990,7 +78554,9 @@ var ts; var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType); if (!typeReferenceNode) return undefined; - var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); // TODO: GH#18217 + var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); + if (!typeParameters) + return undefined; var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]); return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters))); } @@ -77001,7 +78567,7 @@ var ts; ts.forEach(node.members, checkSourceElement); if (produceDiagnostics) { var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - checkIndexConstraints(type); + checkIndexConstraints(type, type.symbol); checkTypeForDuplicateIndexSignatures(node); checkObjectTypeForDuplicateDeclarations(node); } @@ -77016,7 +78582,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 !== 195 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 196 /* NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } @@ -77065,7 +78631,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 205 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 206 /* 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)); } @@ -77096,6 +78662,7 @@ var ts; checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node); } function checkMappedType(node) { + checkGrammarMappedType(node); checkSourceElement(node.typeParameter); checkSourceElement(node.nameType); checkSourceElement(node.type); @@ -77112,6 +78679,12 @@ var ts; checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter)); } } + function checkGrammarMappedType(node) { + var _a; + if ((_a = node.members) === null || _a === void 0 ? void 0 : _a.length) { + return grammarErrorOnNode(node.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); + } + } function checkThisType(node) { getTypeFromThisTypeNode(node); } @@ -77123,7 +78696,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 187 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 188 /* 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); @@ -77146,10 +78719,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 === 183 /* OptionalType */) { + if (node.type.kind === 184 /* 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 === 184 /* RestType */) { + if (node.type.kind === 185 /* 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); @@ -77162,9 +78735,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 !== 256 /* InterfaceDeclaration */ && - n.parent.kind !== 255 /* ClassDeclaration */ && - n.parent.kind !== 224 /* ClassExpression */ && + if (n.parent.kind !== 257 /* InterfaceDeclaration */ && + n.parent.kind !== 256 /* ClassDeclaration */ && + n.parent.kind !== 225 /* 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 @@ -77260,7 +78833,7 @@ 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 === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */) && + var reportError = (node.kind === 168 /* MethodDeclaration */ || node.kind === 167 /* MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -77302,7 +78875,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 8388608 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 256 /* InterfaceDeclaration */ || node.parent.kind === 180 /* TypeLiteral */) || inAmbientContext; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 257 /* InterfaceDeclaration */ || node.parent.kind === 181 /* TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -77313,10 +78886,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 === 255 /* ClassDeclaration */ || node.kind === 224 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 256 /* ClassDeclaration */ || node.kind === 225 /* ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 254 /* FunctionDeclaration */ || node.kind === 167 /* MethodDeclaration */ || node.kind === 166 /* MethodSignature */ || node.kind === 169 /* Constructor */) { + if (node.kind === 255 /* FunctionDeclaration */ || node.kind === 168 /* MethodDeclaration */ || node.kind === 167 /* MethodSignature */ || node.kind === 170 /* Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -77361,12 +78934,12 @@ var ts; }); } if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 255 /* ClassDeclaration */; }) + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 256 /* ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 255 /* ClassDeclaration */ + var diagnostic = declaration.kind === 256 /* ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 254 /* FunctionDeclaration */ + : declaration.kind === 255 /* FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -77457,26 +79030,26 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 256 /* InterfaceDeclaration */: - case 257 /* TypeAliasDeclaration */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 340 /* JSDocTypedefTag */: - case 333 /* JSDocCallbackTag */: - case 334 /* JSDocEnumTag */: + case 343 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: + case 337 /* JSDocEnumTag */: return 2 /* ExportType */; - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 255 /* ClassDeclaration */: - case 258 /* EnumDeclaration */: - case 294 /* EnumMember */: + case 256 /* ClassDeclaration */: + case 259 /* EnumDeclaration */: + case 297 /* EnumMember */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 300 /* SourceFile */: + case 303 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 269 /* ExportAssignment */: - case 219 /* BinaryExpression */: + case 270 /* ExportAssignment */: + case 220 /* 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 @@ -77486,17 +79059,19 @@ 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 263 /* ImportEqualsDeclaration */: - case 266 /* NamespaceImport */: - case 265 /* ImportClause */: - var result_12 = 0 /* None */; + case 264 /* ImportEqualsDeclaration */: + case 267 /* NamespaceImport */: + case 266 /* ImportClause */: + var result_11 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); - 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 + ts.forEach(target.declarations, function (d) { + result_11 |= getDeclarationSpaces(d); + }); + return result_11; + case 253 /* VariableDeclaration */: + case 202 /* BindingElement */: + case 255 /* FunctionDeclaration */: + case 269 /* 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});` @@ -77539,6 +79114,10 @@ var ts; if (isReferenceToType(type, getGlobalPromiseType(/*reportErrors*/ false))) { return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } + // primitives with a `{ then() }` won't be unwrapped/adopted. + if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + return undefined; + } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; @@ -77566,21 +79145,77 @@ var ts; /** * Gets the "awaited type" of a type. * @param type The type to await. + * @param withAlias When `true`, wraps the "awaited type" in `Awaited` if needed. * @remarks The "awaited type" of an expression is its "promised type" if the expression is a * Promise-like type; otherwise, it is the type of the expression. This is used to reflect * The runtime behavior of the `await` keyword. */ - function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) { - var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); + function checkAwaitedType(type, withAlias, errorNode, diagnosticMessage, arg0) { + var awaitedType = withAlias ? + getAwaitedType(type, errorNode, diagnosticMessage, arg0) : + getAwaitedTypeNoAlias(type, errorNode, diagnosticMessage, arg0); return awaitedType || errorType; } /** - * Determines whether a type has a callable `then` member. + * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { + if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + // primitive types cannot be considered "thenable" since they are not objects. + return false; + } var thenFunction = getTypeOfPropertyOfType(type, "then"); return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; } + function isAwaitedTypeInstantiation(type) { + var _a; + if (type.flags & 16777216 /* Conditional */) { + var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); + return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; + } + return false; + } + /** + * For a generic `Awaited`, gets `T`. + */ + function unwrapAwaitedType(type) { + return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : + type; + } + function createAwaitedTypeIfNeeded(type) { + // We wrap type `T` in `Awaited` based on the following conditions: + // - `T` is not already an `Awaited`, and + // - `T` is generic, and + // - One of the following applies: + // - `T` has no base constraint, or + // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or + // - The base constraint of `T` is an object type with a callable `then` method. + if (isTypeAny(type)) { + return type; + } + // If this is already an `Awaited`, just return it. This helps to avoid `Awaited>` in higher-order. + if (isAwaitedTypeInstantiation(type)) { + return type; + } + // Only instantiate `Awaited` if `T` contains possibly non-primitive types. + if (isGenericObjectType(type)) { + var baseConstraint = getBaseConstraintOfType(type); + // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, + // or is promise-like. + if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { + // Nothing to do if `Awaited` doesn't exist + var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); + if (awaitedSymbol) { + // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where + // an `Awaited` would suffice. + return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); + } + } + } + ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like."); + return type; + } /** * Gets the "awaited type" of a type. * @@ -77592,22 +79227,31 @@ var ts; * This is used to reflect the runtime behavior of the `await` keyword. */ function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { + var awaitedType = getAwaitedTypeNoAlias(type, errorNode, diagnosticMessage, arg0); + return awaitedType && createAwaitedTypeIfNeeded(awaitedType); + } + /** + * Gets the "awaited type" of a type without introducing an `Awaited` wrapper. + * + * @see {@link getAwaitedType} + */ + function getAwaitedTypeNoAlias(type, errorNode, diagnosticMessage, arg0) { if (isTypeAny(type)) { return type; } + // If this is already an `Awaited`, just return it. This avoids `Awaited>` in higher-order + if (isAwaitedTypeInstantiation(type)) { + return type; + } + // If we've already cached an awaited type, return a possible `Awaited` for it. var typeAsAwaitable = type; if (typeAsAwaitable.awaitedTypeOfType) { return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - // - return typeAsAwaitable.awaitedTypeOfType = - mapType(type, errorNode ? function (constituentType) { return getAwaitedTypeWorker(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeWorker); - } - function getAwaitedTypeWorker(type, errorNode, diagnosticMessage, arg0) { - var typeAsAwaitable = type; - if (typeAsAwaitable.awaitedTypeOfType) { - return typeAsAwaitable.awaitedTypeOfType; + if (type.flags & 1048576 /* Union */) { + var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; + return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); } var promisedType = getPromisedTypeOfPromise(type); if (promisedType) { @@ -77653,7 +79297,7 @@ var ts; // Keep track of the type we're about to unwrap to avoid bad recursive promise types. // See the comments above for more information. awaitedTypeStack.push(type.id); - var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0); + var awaitedType = getAwaitedTypeNoAlias(promisedType, errorNode, diagnosticMessage, arg0); awaitedTypeStack.pop(); if (!awaitedType) { return undefined; @@ -77677,8 +79321,7 @@ var ts; // be treated as a promise, they can cast to . if (isThenableType(type)) { if (errorNode) { - if (!diagnosticMessage) - return ts.Debug.fail(); + ts.Debug.assertIsDefined(diagnosticMessage); error(errorNode, diagnosticMessage, arg0); } return undefined; @@ -77724,21 +79367,21 @@ var ts; // var returnType = getTypeFromTypeNode(returnTypeNode); if (languageVersion >= 2 /* ES2015 */) { - if (returnType === errorType) { + if (isErrorType(returnType)) { return; } var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. - error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedType(returnType) || voidType)); + error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_Did_you_mean_to_write_Promise_0, typeToString(getAwaitedTypeNoAlias(returnType) || voidType)); return; } } else { // Always mark the type node as referenced if it points to a value markTypeNodeAsReferenced(returnTypeNode); - if (returnType === errorType) { + if (isErrorType(returnType)) { return; } var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode); @@ -77748,7 +79391,7 @@ var ts; } var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; - if (promiseConstructorType === errorType) { + if (isErrorType(promiseConstructorType)) { 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); } @@ -77775,7 +79418,7 @@ var ts; return; } } - checkAwaitedType(returnType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); + checkAwaitedType(returnType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } /** Check a decorator */ function checkDecorator(node) { @@ -77789,24 +79432,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 162 /* Parameter */: + case 163 /* 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 165 /* PropertyDeclaration */: + case 166 /* 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 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -77853,15 +79496,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 186 /* IntersectionType */: - case 185 /* UnionType */: + case 187 /* IntersectionType */: + case 186 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 187 /* ConditionalType */: + case 188 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 189 /* ParenthesizedType */: - case 195 /* NamedTupleMember */: + case 190 /* ParenthesizedType */: + case 196 /* NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 176 /* TypeReference */: + case 177 /* TypeReference */: return node.typeName; } } @@ -77870,13 +79513,13 @@ var ts; var commonEntityName; 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 */) { + while (typeNode.kind === 190 /* ParenthesizedType */ || typeNode.kind === 196 /* NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 142 /* NeverKeyword */) { + if (typeNode.kind === 143 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 194 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 195 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 152 /* 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); @@ -77922,14 +79565,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 162 /* Parameter */) { + if (node.kind === 163 /* 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 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -77938,23 +79581,23 @@ var ts; } } break; - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - var otherKind = node.kind === 170 /* GetAccessor */ ? 171 /* SetAccessor */ : 170 /* GetAccessor */; + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + var otherKind = node.kind === 171 /* GetAccessor */ ? 172 /* SetAccessor */ : 171 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 167 /* MethodDeclaration */: + case 168 /* 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 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 162 /* Parameter */: + case 163 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -77982,6 +79625,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); } checkSourceElement(node.typeExpression); + checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); } function checkJSDocTemplateTag(node) { checkSourceElement(node.constraint); @@ -78016,7 +79660,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 === 159 /* 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 === 160 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -78056,11 +79700,17 @@ var ts; } } } + function checkJSDocAccessibilityModifiers(node) { + var host = ts.getJSDocHost(node); + if (host && ts.isPrivateIdentifierClassElementDeclaration(host)) { + error(node, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier); + } + } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { case 79 /* Identifier */: return node; - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -78074,7 +79724,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 === 160 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 161 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -78100,7 +79750,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 166 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 167 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -78142,42 +79792,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 300 /* SourceFile */: - case 259 /* ModuleDeclaration */: - case 233 /* Block */: - case 261 /* CaseBlock */: - case 240 /* ForStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: + case 303 /* SourceFile */: + case 260 /* ModuleDeclaration */: + case 234 /* Block */: + case 262 /* CaseBlock */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 169 /* Constructor */: - case 211 /* FunctionExpression */: - case 254 /* FunctionDeclaration */: - case 212 /* ArrowFunction */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 170 /* Constructor */: + case 212 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 213 /* ArrowFunction */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 166 /* MethodSignature */: - case 172 /* CallSignature */: - case 173 /* ConstructSignature */: - case 177 /* FunctionType */: - case 178 /* ConstructorType */: - case 257 /* TypeAliasDeclaration */: - case 256 /* InterfaceDeclaration */: + case 167 /* MethodSignature */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: + case 258 /* TypeAliasDeclaration */: + case 257 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 188 /* InferType */: + case 189 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -78197,11 +79847,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 167 /* MethodDeclaration */: - case 165 /* PropertyDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - if (member.kind === 171 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 168 /* MethodDeclaration */: + case 166 /* PropertyDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + if (member.kind === 172 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -78212,7 +79862,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 169 /* Constructor */: + case 170 /* 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 */)) { @@ -78220,9 +79870,9 @@ var ts; } } break; - case 174 /* IndexSignature */: - case 232 /* SemicolonClassElement */: - case 168 /* ClassStaticBlockDeclaration */: + case 175 /* IndexSignature */: + case 233 /* SemicolonClassElement */: + case 169 /* ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -78250,7 +79900,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 188 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 189 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -78356,7 +80006,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 266 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 267 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -78374,7 +80024,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 === 252 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 253 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 253 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 254 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -78395,7 +80045,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 === 235 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 236 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -78409,22 +80059,22 @@ var ts; switch (name.kind) { case 79 /* Identifier */: return ts.idText(name); - case 200 /* ArrayBindingPattern */: - case 199 /* ObjectBindingPattern */: + case 201 /* ArrayBindingPattern */: + case 200 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 265 /* ImportClause */ || node.kind === 268 /* ImportSpecifier */ || node.kind === 266 /* NamespaceImport */; + return node.kind === 266 /* ImportClause */ || node.kind === 269 /* ImportSpecifier */ || node.kind === 267 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 265 /* ImportClause */ ? decl : decl.kind === 266 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 266 /* ImportClause */ ? decl : decl.kind === 267 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 233 /* Block */) { + if (node.kind === 234 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -78459,13 +80109,13 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - 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 */) { + if (node.kind === 166 /* PropertyDeclaration */ || + node.kind === 165 /* PropertySignature */ || + node.kind === 168 /* MethodDeclaration */ || + node.kind === 167 /* MethodSignature */ || + node.kind === 171 /* GetAccessor */ || + node.kind === 172 /* SetAccessor */ || + node.kind === 294 /* PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } @@ -78519,7 +80169,7 @@ var ts; } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { // No need to check for require or exports for ES6 modules and later - if (moduleKind >= ts.ModuleKind.ES2015) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(moduleKind >= ts.ModuleKind.Node12 && ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { return; } if (!name || !needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { @@ -78531,7 +80181,7 @@ 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 === 300 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 303 /* 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)); } @@ -78546,7 +80196,7 @@ 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 === 300 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 303 /* 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)); } @@ -78646,7 +80296,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 === 252 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 253 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -78658,17 +80308,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 253 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 235 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 254 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 236 /* 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 === 233 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 260 /* ModuleBlock */ || - container.kind === 259 /* ModuleDeclaration */ || - container.kind === 300 /* SourceFile */); + (container.kind === 234 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 261 /* ModuleBlock */ || + container.kind === 260 /* ModuleDeclaration */ || + container.kind === 303 /* 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 @@ -78699,7 +80349,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 === 160 /* ComputedPropertyName */) { + if (node.name.kind === 161 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -78710,7 +80360,7 @@ var ts; checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 160 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 161 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -78731,7 +80381,7 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 200 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 201 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -78743,7 +80393,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 !== 241 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 242 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -78785,7 +80435,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 !== 241 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 242 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -78799,7 +80449,7 @@ var ts; // Node is a secondary declaration, check that type is identical to primary declaration and check that // initializer is consistent with type associated with the node var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); - if (type !== errorType && declarationType !== errorType && + if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && !(symbol.flags & 67108864 /* Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); @@ -78811,10 +80461,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */) { + if (node.kind !== 166 /* PropertyDeclaration */ && node.kind !== 165 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 252 /* VariableDeclaration */ || node.kind === 201 /* BindingElement */) { + if (node.kind === 253 /* VariableDeclaration */ || node.kind === 202 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -78822,7 +80472,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 165 /* PropertyDeclaration */ || nextDeclaration.kind === 164 /* PropertySignature */ + var message = nextDeclaration.kind === 166 /* PropertyDeclaration */ || nextDeclaration.kind === 165 /* 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); @@ -78832,8 +80482,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 162 /* Parameter */ && right.kind === 252 /* VariableDeclaration */) || - (left.kind === 252 /* VariableDeclaration */ && right.kind === 162 /* Parameter */)) { + if ((left.kind === 163 /* Parameter */ && right.kind === 253 /* VariableDeclaration */) || + (left.kind === 253 /* VariableDeclaration */ && right.kind === 163 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -78875,7 +80525,7 @@ var ts; var type = checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 234 /* EmptyStatement */) { + if (node.thenStatement.kind === 235 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -78886,7 +80536,7 @@ var ts; if (getFalsyFlags(type)) return; var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; - if (ts.isPropertyAccessExpression(location) && ts.isAssertionExpression(ts.skipParentheses(location.expression))) { + if (ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression)) { return; } var testedNode = ts.isIdentifier(location) ? location @@ -78998,12 +80648,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 253 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 254 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 253 /* VariableDeclarationList */) { + if (node.initializer.kind === 254 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -79043,14 +80693,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 === 253 /* VariableDeclarationList */) { + if (node.initializer.kind === 254 /* 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 === 202 /* ArrayLiteralExpression */ || varExpr.kind === 203 /* ObjectLiteralExpression */) { + if (varExpr.kind === 203 /* ArrayLiteralExpression */ || varExpr.kind === 204 /* 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. @@ -79082,7 +80732,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 === 253 /* VariableDeclarationList */) { + if (node.initializer.kind === 254 /* 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); @@ -79096,7 +80746,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 === 202 /* ArrayLiteralExpression */ || varExpr.kind === 203 /* ObjectLiteralExpression */) { + if (varExpr.kind === 203 /* ArrayLiteralExpression */ || varExpr.kind === 204 /* 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)) { @@ -79394,6 +81044,10 @@ var ts; if (iterationTypes === anyIterationTypes) return anyIterationTypes; var yieldType = iterationTypes.yieldType, returnType = iterationTypes.returnType, nextType = iterationTypes.nextType; + // if we're requesting diagnostics, report errors for a missing `Awaited`. + if (errorNode) { + getGlobalAwaitedSymbol(/*reportErrors*/ true); + } return createIterationTypes(getAwaitedType(yieldType, errorNode) || anyType, getAwaitedType(returnType, errorNode) || anyType, nextType); } /** @@ -79414,7 +81068,9 @@ var ts; var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return iterationTypes; + return use & 8 /* ForOfFlag */ ? + getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : + iterationTypes; } } if (use & 1 /* AllowsSyncIterablesFlag */) { @@ -79494,14 +81150,14 @@ var ts; // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use // different definitions. var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType; - return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType)); + return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(resolver.resolveIterationType(yieldType, /*errorNode*/ undefined) || yieldType, resolver.resolveIterationType(returnType, /*errorNode*/ undefined) || returnType, nextType)); } // As an optimization, if the type is an instantiation of the following global type, then // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; - return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType)); + return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(resolver.resolveIterationType(yieldType, /*errorNode*/ undefined) || yieldType, resolver.resolveIterationType(returnType, /*errorNode*/ undefined) || returnType, nextType)); } } function getPropertyNameForKnownSymbolName(symbolName) { @@ -79793,11 +81449,10 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var _a, _b; var isGenerator = !!(functionFlags & 1 /* Generator */); var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? (_a = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync)) !== null && _a !== void 0 ? _a : errorType : - isAsync ? (_b = getAwaitedType(returnType)) !== null && _b !== void 0 ? _b : errorType : + return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : + isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { @@ -79824,12 +81479,12 @@ var ts; var functionFlags = ts.getFunctionFlags(container); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 171 /* SetAccessor */) { + if (container.kind === 172 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 169 /* Constructor */) { + else if (container.kind === 170 /* 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); } @@ -79837,7 +81492,7 @@ var ts; 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) + ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { // If the function has a return type, but promisedType is @@ -79847,7 +81502,7 @@ var ts; } } } - else if (container.kind !== 169 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 170 /* 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); } @@ -79876,7 +81531,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 === 288 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 289 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -79885,7 +81540,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 287 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 288 /* 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. @@ -79917,7 +81572,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 248 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 249 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -79975,7 +81630,7 @@ var ts; checkBlock(node.finallyBlock); } } - function checkIndexConstraints(type, isStaticIndex) { + function checkIndexConstraints(type, symbol, isStaticIndex) { var indexInfos = getIndexInfosOfType(type); if (indexInfos.length === 0) { return; @@ -79986,15 +81641,15 @@ var ts; checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } - var typeDeclaration = type.symbol.valueDeclaration; + var typeDeclaration = 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 symbol_3 = getSymbolOfNode(member); + checkIndexConstraintForProperty(type, symbol_3, getTypeOfExpression(member.name.expression), getNonMissingTypeOfSymbol(symbol_3)); } } } @@ -80012,9 +81667,9 @@ var ts; 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 interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined; + var localPropDeclaration = declaration && declaration.kind === 220 /* BinaryExpression */ || + name && name.kind === 161 /* 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 @@ -80034,7 +81689,7 @@ var ts; 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 interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 257 /* InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; var _loop_28 = function (info) { if (info === checkInfo) @@ -80075,8 +81730,8 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion === 1 /* ES5 */ && name.escapedText === "Object" - && moduleKind < ts.ModuleKind.ES2015) { + if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } } @@ -80110,7 +81765,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 176 /* TypeReference */) { + if (node.kind === 177 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -80281,7 +81936,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType_1); } } - checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType); + checkMembersForOverrideModifier(node, type, typeWithThis, staticType); var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node); if (implementedTypeNodes) { for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { @@ -80292,7 +81947,7 @@ var ts; checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getReducedType(getTypeFromTypeNode(typeRefNode)); - if (t !== errorType) { + if (!isErrorType(t)) { if (isValidBaseType(t)) { var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : @@ -80310,14 +81965,13 @@ var ts; } } if (produceDiagnostics) { - checkIndexConstraints(type); - checkIndexConstraints(staticType, /*isStaticIndex*/ true); + checkIndexConstraints(type, symbol); + checkIndexConstraints(staticType, symbol, /*isStaticIndex*/ true); checkTypeForDuplicateIndexSignatures(node); checkPropertyInitialization(node); } } - function checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType) { - var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) { var baseTypeNode = ts.getEffectiveBaseTypeNode(node); var baseTypes = baseTypeNode && getBaseTypes(type); var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined; @@ -80329,56 +81983,100 @@ var ts; if (ts.isConstructorDeclaration(member)) { ts.forEach(member.parameters, function (param) { if (ts.isParameterPropertyDeclaration(param, member)) { - checkClassMember(param, /*memberIsParameterProperty*/ true); + checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, param, + /* memberIsParameterProperty */ true); } }); } - checkClassMember(member); + checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, + /* memberIsParameterProperty */ false); }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; _loop_29(member); } - function checkClassMember(member, memberIsParameterProperty) { - var hasOverride = ts.hasOverrideModifier(member); - var hasStatic = ts.isStatic(member); - if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) { - var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); - if (!declaredProp) { - return; - } - var thisType = hasStatic ? staticType : typeWithThis; - var baseType = hasStatic ? baseStaticType : baseWithThis; - var prop = getPropertyOfType(thisType, declaredProp.escapedName); - var baseProp = getPropertyOfType(baseType, declaredProp.escapedName); - var baseClassName = typeToString(baseWithThis); - if (prop && !baseProp && hasOverride) { - var suggestion = getSuggestedSymbolForNonexistentClassMember(ts.symbolName(declaredProp), baseType); + } + /** + * @param member Existing member node to be checked. + * Note: `member` cannot be a synthetic node. + */ + function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) { + if (reportErrors === void 0) { reportErrors = true; } + var declaredProp = member.name + && getSymbolAtLocation(member.name) + || getSymbolAtLocation(member); + if (!declaredProp) { + return 0 /* Ok */; + } + return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); + } + /** + * Checks a class member declaration for either a missing or an invalid `override` modifier. + * Note: this function can be used for speculative checking, + * i.e. checking a member that does not yet exist in the program. + * An example of that would be to call this function in a completions scenario, + * when offering a method declaration as completion. + * @param errorNode The node where we should report an error, or undefined if we should not report errors. + */ + function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { + var isJs = ts.isInJSFile(node); + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { + var memberEscapedName = ts.escapeLeadingUnderscores(memberName); + var thisType = memberIsStatic ? staticType : typeWithThis; + var baseType = memberIsStatic ? baseStaticType : baseWithThis; + var prop = getPropertyOfType(thisType, memberEscapedName); + var baseProp = getPropertyOfType(baseType, memberEscapedName); + var baseClassName = typeToString(baseWithThis); + if (prop && !baseProp && memberHasOverrideModifier) { + if (errorNode) { + var suggestion = getSuggestedSymbolForNonexistentClassMember(memberName, baseType); // Again, using symbol name: note that's different from `symbol.escapedName` 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); + error(errorNode, isJs ? + ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1 : + 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(errorNode, isJs ? + ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : + 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.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { - var baseHasAbstract = ts.some(baseProp.declarations, function (d) { return ts.hasAbstractModifier(d); }); - if (hasOverride) { - return; - } - if (!baseHasAbstract) { + return 2 /* HasInvalidOverride */; + } + else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { + var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); + if (memberHasOverrideModifier) { + return 0 /* Ok */; + } + if (!baseHasAbstract) { + if (errorNode) { var diag = memberIsParameterProperty ? - ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0 : - ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; - error(member, diag, baseClassName); + isJs ? + ts.Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 : + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0 : + isJs ? + ts.Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 : + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; + error(errorNode, diag, baseClassName); } - else if (ts.hasAbstractModifier(member) && baseHasAbstract) { - error(member, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); + return 1 /* NeedsOverride */; + } + else if (memberHasAbstractModifier && baseHasAbstract) { + if (errorNode) { + error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } + return 1 /* NeedsOverride */; } } - else if (hasOverride) { + } + else if (memberHasOverrideModifier) { + if (errorNode) { var className = typeToString(type); - error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); + error(errorNode, isJs ? + ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } + return 2 /* HasInvalidOverride */; } + return 0 /* Ok */; } 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 @@ -80421,6 +82119,31 @@ var ts; } } } + /** + * Checks a member declaration node to see if has a missing or invalid `override` modifier. + * @param node Class-like node where the member is declared. + * @param member Member declaration node. + * Note: `member` can be a synthetic node without a parent. + */ + function getMemberOverrideModifierStatus(node, member) { + if (!member.name) { + return 0 /* Ok */; + } + var symbol = getSymbolOfNode(node); + var type = getDeclaredTypeOfSymbol(symbol); + var typeWithThis = getTypeWithThisArgument(type); + var staticType = getTypeOfSymbol(symbol); + var baseTypeNode = ts.getEffectiveBaseTypeNode(node); + 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 memberHasOverrideModifier = member.parent + ? ts.hasOverrideModifier(member) + : ts.hasSyntacticModifier(member, 16384 /* Override */); + var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); + return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), + /* memberIsParameterProperty */ false, memberName); + } function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags @@ -80428,7 +82151,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 255 /* ClassDeclaration */ || d.kind === 256 /* InterfaceDeclaration */; + return d.kind === 256 /* ClassDeclaration */ || d.kind === 257 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -80484,7 +82207,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 224 /* ClassExpression */) { + if (derivedClassDecl.kind === 225 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -80505,7 +82228,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 === 256 /* InterfaceDeclaration */ + || base.valueDeclaration && base.valueDeclaration.parent.kind === 257 /* 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 @@ -80520,7 +82243,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 === 165 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 166 /* PropertyDeclaration */ && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 128 /* Abstract */) @@ -80566,7 +82289,9 @@ var ts; return properties; } var seen = new ts.Map(); - ts.forEach(properties, function (p) { seen.set(p.escapedName, p); }); + ts.forEach(properties, function (p) { + seen.set(p.escapedName, p); + }); for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); @@ -80586,7 +82311,9 @@ var ts; return true; } var seen = new ts.Map(); - ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.escapedName, { prop: p, containingType: type }); }); + ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { + seen.set(p.escapedName, { prop: p, containingType: type }); + }); var ok = true; for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) { var base = baseTypes_3[_i]; @@ -80636,7 +82363,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 165 /* PropertyDeclaration */ && + return node.kind === 166 /* PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -80677,7 +82404,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 256 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 257 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -80687,7 +82414,7 @@ var ts; var baseType = _a[_i]; checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1); } - checkIndexConstraints(type); + checkIndexConstraints(type, symbol); } } checkObjectTypeForDuplicateDeclarations(node); @@ -80710,7 +82437,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 137 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* 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); } @@ -80796,7 +82523,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -80806,7 +82533,7 @@ var ts; } } break; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -80835,7 +82562,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return evaluate(expr.expression); case 79 /* Identifier */: var identifier = expr; @@ -80843,14 +82570,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 205 /* ElementAccessExpression */: - case 204 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: + case 205 /* 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 === 204 /* PropertyAccessExpression */) { + if (ex.kind === 205 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -80883,8 +82610,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 79 /* Identifier */ || - node.kind === 204 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 205 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 205 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 206 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -80918,7 +82645,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 !== 258 /* EnumDeclaration */) { + if (declaration.kind !== 259 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -80947,8 +82674,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 === 255 /* ClassDeclaration */ || - (declaration.kind === 254 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 256 /* ClassDeclaration */ || + (declaration.kind === 255 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } @@ -81012,7 +82739,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, 255 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 256 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -81063,23 +82790,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 235 /* VariableStatement */: + case 236 /* 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 269 /* ExportAssignment */: - case 270 /* ExportDeclaration */: + case 270 /* ExportAssignment */: + case 271 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 263 /* ImportEqualsDeclaration */: - case 264 /* ImportDeclaration */: + case 264 /* ImportEqualsDeclaration */: + case 265 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 201 /* BindingElement */: - case 252 /* VariableDeclaration */: + case 202 /* BindingElement */: + case 253 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -81090,12 +82817,12 @@ var ts; break; } // falls through - case 255 /* ClassDeclaration */: - case 258 /* EnumDeclaration */: - case 254 /* FunctionDeclaration */: - case 256 /* InterfaceDeclaration */: - case 259 /* ModuleDeclaration */: - case 257 /* TypeAliasDeclaration */: + case 256 /* ClassDeclaration */: + case 259 /* EnumDeclaration */: + case 255 /* FunctionDeclaration */: + case 257 /* InterfaceDeclaration */: + case 260 /* ModuleDeclaration */: + case 258 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -81118,12 +82845,12 @@ var ts; switch (node.kind) { case 79 /* Identifier */: return node; - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: do { node = node.left; } while (node.kind !== 79 /* Identifier */); return node; - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; @@ -81143,9 +82870,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - 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 */ ? + var inAmbientExternalModule = node.parent.kind === 261 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 303 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 271 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -81180,18 +82907,46 @@ var ts; (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 273 /* ExportSpecifier */ ? + var message = node.kind === 274 /* 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 === 273 /* ExportSpecifier */ - && !node.parent.parent.isTypeOnly - && !(target.flags & 111551 /* Value */) + && !ts.isTypeOnlyImportOrExportDeclaration(node) && !(node.flags & 8388608 /* Ambient */)) { - error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type); + var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); + var isType = !(target.flags & 111551 /* Value */); + if (isType || typeOnlyAlias) { + switch (node.kind) { + case 266 /* ImportClause */: + case 269 /* ImportSpecifier */: + case 264 /* ImportEqualsDeclaration */: { + if (compilerOptions.preserveValueImports) { + ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); + var message = isType + ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled + : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; + var name = ts.idText(node.kind === 269 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); + } + break; + } + case 274 /* ExportSpecifier */: { + // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. + // The exception is that `import type { A } from './a'; export { A }` is allowed + // because single-file analysis can determine that the export should be dropped. + if (ts.getSourceFileOfNode(typeOnlyAlias) !== ts.getSourceFileOfNode(node)) { + var message = isType + ? ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type + : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_re_exported_using_a_type_only_re_export_when_isolatedModules_is_enabled; + var name = ts.idText(node.propertyName || node.name); + addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); + return; + } + } + } + } } if (ts.isImportSpecifier(node) && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); }))) { addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName); @@ -81201,13 +82956,24 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 268 /* ImportSpecifier */ && + if (node.kind === 269 /* ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && - compilerOptions.esModuleInterop && - moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { + ts.getESModuleInterop(compilerOptions) && + moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { checkExternalEmitHelpers(node, 131072 /* ImportDefault */); } } + function checkAssertClause(declaration) { + var _a; + if (declaration.assertClause) { + if (moduleKind !== ts.ModuleKind.ESNext) { + return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext); + } + if (ts.isImportDeclaration(declaration) ? (_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.isTypeOnly : declaration.isTypeOnly) { + return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Import_assertions_cannot_be_used_with_type_only_imports_or_exports); + } + } + } function checkImportDeclaration(node) { if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. @@ -81223,9 +82989,9 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 266 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 267 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); - if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) { + if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; checkExternalEmitHelpers(node, 65536 /* ImportStar */); } @@ -81239,6 +83005,7 @@ var ts; } } } + checkAssertClause(node); } function checkImportEqualsDeclaration(node) { if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { @@ -81251,7 +83018,7 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 275 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 276 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { @@ -81270,7 +83037,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -81286,7 +83053,7 @@ var ts; grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 2097152 /* CreateBinding */); + checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -81294,10 +83061,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 260 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 260 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 261 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 261 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; - if (node.parent.kind !== 300 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 303 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -81311,12 +83078,12 @@ var ts; else if (node.exportClause) { checkAliasSymbol(node.exportClause); } - if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { + if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { if (node.exportClause) { // export * as ns from "foo"; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop - if (compilerOptions.esModuleInterop) { + if (ts.getESModuleInterop(compilerOptions)) { checkExternalEmitHelpers(node, 65536 /* ImportStar */); } } @@ -81327,17 +83094,22 @@ var ts; } } } + checkAssertClause(node); } function checkGrammarExportDeclaration(node) { var _a; - 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); + if (node.isTypeOnly) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 272 /* NamedExports */) { + return checkGrammarNamedImportsOrExports(node.exportClause); + } + else { + return grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); + } } - return !isTypeOnlyExportStar; + return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 300 /* SourceFile */ || node.parent.kind === 260 /* ModuleBlock */ || node.parent.kind === 259 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 303 /* SourceFile */ || node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 260 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -81399,9 +83171,9 @@ var ts; } } else { - if (compilerOptions.esModuleInterop && + if (ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && - moduleKind < ts.ModuleKind.ES2015 && + (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { checkExternalEmitHelpers(node, 131072 /* ImportDefault */); } @@ -81415,8 +83187,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 === 300 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 259 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 303 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 260 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -81429,6 +83201,10 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } + var typeAnnotationNode = ts.getEffectiveTypeAnnotationNode(node); + if (typeAnnotationNode) { + checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); + } if (node.expression.kind === 79 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); @@ -81456,7 +83232,7 @@ var ts; grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { - if (moduleKind >= ts.ModuleKind.ES2015) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } @@ -81540,173 +83316,177 @@ 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 259 /* ModuleDeclaration */: - case 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: - case 254 /* FunctionDeclaration */: + case 260 /* ModuleDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 255 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 235 /* FirstStatement */ && kind <= 251 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 236 /* FirstStatement */ && kind <= 252 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 161 /* TypeParameter */: + case 162 /* TypeParameter */: return checkTypeParameter(node); - case 162 /* Parameter */: + case 163 /* Parameter */: return checkParameter(node); - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return checkPropertyDeclaration(node); - case 164 /* PropertySignature */: + case 165 /* PropertySignature */: return checkPropertySignature(node); - case 178 /* ConstructorType */: - case 177 /* FunctionType */: - case 172 /* CallSignature */: - case 173 /* ConstructSignature */: - case 174 /* IndexSignature */: + case 179 /* ConstructorType */: + case 178 /* FunctionType */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 175 /* IndexSignature */: return checkSignatureDeclaration(node); - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: return checkMethodDeclaration(node); - case 168 /* ClassStaticBlockDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 169 /* Constructor */: + case 170 /* Constructor */: return checkConstructorDeclaration(node); - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return checkAccessorDeclaration(node); - case 176 /* TypeReference */: + case 177 /* TypeReference */: return checkTypeReferenceNode(node); - case 175 /* TypePredicate */: + case 176 /* TypePredicate */: return checkTypePredicate(node); - case 179 /* TypeQuery */: + case 180 /* TypeQuery */: return checkTypeQuery(node); - case 180 /* TypeLiteral */: + case 181 /* TypeLiteral */: return checkTypeLiteral(node); - case 181 /* ArrayType */: + case 182 /* ArrayType */: return checkArrayType(node); - case 182 /* TupleType */: + case 183 /* TupleType */: return checkTupleType(node); - case 185 /* UnionType */: - case 186 /* IntersectionType */: + case 186 /* UnionType */: + case 187 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 189 /* ParenthesizedType */: - case 183 /* OptionalType */: - case 184 /* RestType */: + case 190 /* ParenthesizedType */: + case 184 /* OptionalType */: + case 185 /* RestType */: return checkSourceElement(node.type); - case 190 /* ThisType */: + case 191 /* ThisType */: return checkThisType(node); - case 191 /* TypeOperator */: + case 192 /* TypeOperator */: return checkTypeOperator(node); - case 187 /* ConditionalType */: + case 188 /* ConditionalType */: return checkConditionalType(node); - case 188 /* InferType */: + case 189 /* InferType */: return checkInferType(node); - case 196 /* TemplateLiteralType */: + case 197 /* TemplateLiteralType */: return checkTemplateLiteralType(node); - case 198 /* ImportType */: + case 199 /* ImportType */: return checkImportType(node); - case 195 /* NamedTupleMember */: + case 196 /* NamedTupleMember */: return checkNamedTupleMember(node); - case 323 /* JSDocAugmentsTag */: + case 326 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 324 /* JSDocImplementsTag */: + case 327 /* JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 340 /* JSDocTypedefTag */: - case 333 /* JSDocCallbackTag */: - case 334 /* JSDocEnumTag */: + case 343 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: + case 337 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 339 /* JSDocTemplateTag */: + case 342 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 338 /* JSDocTypeTag */: + case 341 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 335 /* JSDocParameterTag */: + case 338 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 342 /* JSDocPropertyTag */: + case 345 /* JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 312 /* JSDocFunctionType */: + case 315 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 310 /* JSDocNonNullableType */: - case 309 /* JSDocNullableType */: - case 307 /* JSDocAllType */: - case 308 /* JSDocUnknownType */: - case 317 /* JSDocTypeLiteral */: + case 313 /* JSDocNonNullableType */: + case 312 /* JSDocNullableType */: + case 310 /* JSDocAllType */: + case 311 /* JSDocUnknownType */: + case 320 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 313 /* JSDocVariadicType */: + case 316 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 304 /* JSDocTypeExpression */: + case 307 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 192 /* IndexedAccessType */: + case 331 /* JSDocPublicTag */: + case 333 /* JSDocProtectedTag */: + case 332 /* JSDocPrivateTag */: + return checkJSDocAccessibilityModifiers(node); + case 193 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 193 /* MappedType */: + case 194 /* MappedType */: return checkMappedType(node); - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 233 /* Block */: - case 260 /* ModuleBlock */: + case 234 /* Block */: + case 261 /* ModuleBlock */: return checkBlock(node); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return checkVariableStatement(node); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: return checkExpressionStatement(node); - case 237 /* IfStatement */: + case 238 /* IfStatement */: return checkIfStatement(node); - case 238 /* DoStatement */: + case 239 /* DoStatement */: return checkDoStatement(node); - case 239 /* WhileStatement */: + case 240 /* WhileStatement */: return checkWhileStatement(node); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return checkForStatement(node); - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: return checkForInStatement(node); - case 242 /* ForOfStatement */: + case 243 /* ForOfStatement */: return checkForOfStatement(node); - case 243 /* ContinueStatement */: - case 244 /* BreakStatement */: + case 244 /* ContinueStatement */: + case 245 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: return checkReturnStatement(node); - case 246 /* WithStatement */: + case 247 /* WithStatement */: return checkWithStatement(node); - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: return checkSwitchStatement(node); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return checkLabeledStatement(node); - case 249 /* ThrowStatement */: + case 250 /* ThrowStatement */: return checkThrowStatement(node); - case 250 /* TryStatement */: + case 251 /* TryStatement */: return checkTryStatement(node); - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 201 /* BindingElement */: + case 202 /* BindingElement */: return checkBindingElement(node); - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: return checkClassDeclaration(node); - case 256 /* InterfaceDeclaration */: + case 257 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 257 /* TypeAliasDeclaration */: + case 258 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return checkImportDeclaration(node); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: return checkExportDeclaration(node); - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: return checkExportAssignment(node); - case 234 /* EmptyStatement */: - case 251 /* DebuggerStatement */: + case 235 /* EmptyStatement */: + case 252 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 274 /* MissingDeclaration */: + case 275 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -81805,33 +83585,33 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 206 /* CallExpression */: - case 207 /* NewExpression */: - case 208 /* TaggedTemplateExpression */: - case 163 /* Decorator */: - case 278 /* JsxOpeningElement */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: + case 209 /* TaggedTemplateExpression */: + case 164 /* Decorator */: + case 279 /* 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 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 224 /* ClassExpression */: + case 225 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 277 /* JsxSelfClosingElement */: + case 278 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 276 /* JsxElement */: + case 277 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -81982,17 +83762,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 300 /* SourceFile */: + case 303 /* SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 224 /* ClassExpression */: + case 225 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -82000,8 +83780,8 @@ 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 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* 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. @@ -82010,7 +83790,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -82054,7 +83834,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 273 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 272 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 274 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 273 /* NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -82068,19 +83848,19 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 161 /* TypeParameter */: - case 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 258 /* EnumDeclaration */: - case 340 /* JSDocTypedefTag */: - case 333 /* JSDocCallbackTag */: - case 334 /* JSDocEnumTag */: + case 162 /* TypeParameter */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 259 /* EnumDeclaration */: + case 343 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: + case 337 /* JSDocEnumTag */: return true; - case 265 /* ImportClause */: + case 266 /* ImportClause */: return node.isTypeOnly; - case 268 /* ImportSpecifier */: - case 273 /* ExportSpecifier */: + case 269 /* ImportSpecifier */: + case 274 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -82088,16 +83868,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 159 /* QualifiedName */) { + while (node.parent.kind === 160 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 176 /* TypeReference */; + return node.parent.kind === 177 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 204 /* PropertyAccessExpression */) { + while (node.parent.kind === 205 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 226 /* ExpressionWithTypeArguments */; + return node.parent.kind === 227 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -82125,13 +83905,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 159 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 160 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 263 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 264 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 269 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 270 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -82157,7 +83937,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 198 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 199 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -82167,7 +83947,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 204 /* PropertyAccessExpression */ && + name.parent.kind === 205 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -82177,7 +83957,7 @@ var ts; } } } - if (name.parent.kind === 269 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 270 /* 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); @@ -82187,7 +83967,7 @@ var ts; } 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, 263 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 264 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -82205,7 +83985,7 @@ var ts; if (isHeritageClauseElementIdentifier(name)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 226 /* ExpressionWithTypeArguments */) { + if (name.parent.kind === 227 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { @@ -82221,10 +84001,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 335 /* JSDocParameterTag */) { + if (name.parent.kind === 338 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 161 /* TypeParameter */ && name.parent.parent.kind === 339 /* JSDocTemplateTag */) { + if (name.parent.kind === 162 /* TypeParameter */ && name.parent.parent.kind === 342 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -82250,12 +84030,15 @@ var ts; } return result; } - else if (name.kind === 204 /* PropertyAccessExpression */ || name.kind === 159 /* QualifiedName */) { + else if (ts.isPrivateIdentifier(name)) { + return getSymbolForPrivateIdentifierExpression(name); + } + else if (name.kind === 205 /* PropertyAccessExpression */ || name.kind === 160 /* QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 204 /* PropertyAccessExpression */) { + if (name.kind === 205 /* PropertyAccessExpression */) { checkPropertyAccessExpression(name, 0 /* Normal */); } else { @@ -82271,10 +84054,11 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 176 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; - return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + var meaning = name.parent.kind === 177 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); + return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 175 /* TypePredicate */) { + if (name.parent.kind === 176 /* TypePredicate */) { return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); } return undefined; @@ -82308,7 +84092,7 @@ var ts; } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 300 /* SourceFile */) { + if (node.kind === 303 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -82331,8 +84115,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 201 /* BindingElement */ && - grandParent.kind === 199 /* ObjectBindingPattern */ && + else if (parent.kind === 202 /* BindingElement */ && + grandParent.kind === 200 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -82354,8 +84138,8 @@ var ts; switch (node.kind) { case 79 /* Identifier */: case 80 /* PrivateIdentifier */: - case 204 /* PropertyAccessExpression */: - case 159 /* QualifiedName */: + case 205 /* PropertyAccessExpression */: + case 160 /* QualifiedName */: return getSymbolOfNameOrPropertyAccessExpression(node); case 108 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -82369,14 +84153,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 190 /* ThisType */: + case 191 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 106 /* SuperKeyword */: return checkExpression(node).symbol; - case 133 /* ConstructorKeyword */: + case 134 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 169 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 170 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -82387,7 +84171,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 === 264 /* ImportDeclaration */ || node.parent.kind === 270 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 265 /* ImportDeclaration */ || node.parent.kind === 271 /* 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); @@ -82409,14 +84193,14 @@ var ts; case 38 /* EqualsGreaterThanToken */: case 84 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 198 /* ImportType */: + case 199 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; 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 */: + case 230 /* MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -82432,7 +84216,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 292 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 295 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -82499,7 +84283,7 @@ var ts; var symbol = getSymbolAtLocation(node); if (symbol) { var declaredType = getDeclaredTypeOfSymbol(symbol); - return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol); + return !isErrorType(declaredType) ? declaredType : getTypeOfSymbol(symbol); } } if (ts.isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) { @@ -82514,23 +84298,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 203 /* ObjectLiteralExpression */ || expr.kind === 202 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 204 /* ObjectLiteralExpression */ || expr.kind === 203 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 242 /* ForOfStatement */) { + if (expr.parent.kind === 243 /* 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 === 219 /* BinaryExpression */) { + if (expr.parent.kind === 220 /* 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 === 291 /* PropertyAssignment */) { + if (expr.parent.kind === 294 /* 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); @@ -82578,7 +84362,7 @@ var ts; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getStringLiteralType(name.text); - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -82696,7 +84480,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) === 300 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 303 /* 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. @@ -82728,7 +84512,7 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 290 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 291 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -82759,7 +84543,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 === 233 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 234 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -82800,28 +84584,28 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 263 /* ImportEqualsDeclaration */: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 265 /* ImportClause */: - case 266 /* NamespaceImport */: - case 268 /* ImportSpecifier */: - case 273 /* ExportSpecifier */: - var symbol = getSymbolOfNode(node) || unknownSymbol; - return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 270 /* ExportDeclaration */: + case 264 /* ImportEqualsDeclaration */: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 266 /* ImportClause */: + case 267 /* NamespaceImport */: + case 269 /* ImportSpecifier */: + case 274 /* ExportSpecifier */: + var symbol = getSymbolOfNode(node); + return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); + case 271 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: return node.expression && node.expression.kind === 79 /* Identifier */ ? - isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 300 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 303 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -82829,6 +84613,9 @@ var ts; return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference); } function isAliasResolvedToValue(symbol) { + if (!symbol) { + return false; + } var target = resolveAlias(symbol); if (target === unknownSymbol) { return true; @@ -82933,15 +84720,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 294 /* EnumMember */: - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 297 /* EnumMember */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 294 /* EnumMember */) { + if (node.kind === 297 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -82994,7 +84781,7 @@ var ts; return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } var type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === errorType) { + if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } else if (type.flags & 3 /* AnyOrUnknown */) { @@ -83034,7 +84821,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(129 /* AnyKeyword */); + return ts.factory.createToken(130 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -83053,7 +84840,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(129 /* AnyKeyword */); + return ts.factory.createToken(130 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -83061,7 +84848,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(129 /* AnyKeyword */); + return ts.factory.createToken(130 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -83218,12 +85005,12 @@ var ts; getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 171 /* SetAccessor */ ? 170 /* GetAccessor */ : 171 /* SetAccessor */; + var otherKind = accessor.kind === 172 /* SetAccessor */ ? 171 /* GetAccessor */ : 172 /* 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 === 171 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 170 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 172 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 171 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -83239,7 +85026,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 300 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 303 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -83276,7 +85063,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 226 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 289 /* HeritageClause */; + return node.parent && node.parent.kind === 227 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 290 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -83288,7 +85075,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 === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 204 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 205 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -83336,7 +85123,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 300 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 303 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -83364,12 +85151,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 259 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 260 /* 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, 300 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 303 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -83506,7 +85293,7 @@ var ts; var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 2097152 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); @@ -83558,7 +85345,8 @@ var ts; case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* CreateBinding */: return "__createBinding"; + case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -83577,14 +85365,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 167 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 168 /* 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 === 170 /* GetAccessor */ || node.kind === 171 /* SetAccessor */) { + else if (node.kind === 171 /* GetAccessor */ || node.kind === 172 /* 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); @@ -83601,21 +85389,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 !== 143 /* ReadonlyKeyword */) { - if (node.kind === 164 /* PropertySignature */ || node.kind === 166 /* MethodSignature */) { + if (modifier.kind !== 144 /* ReadonlyKeyword */) { + if (node.kind === 165 /* PropertySignature */ || node.kind === 167 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 174 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 175 /* 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 85 /* ConstKeyword */: - if (node.kind !== 258 /* EnumDeclaration */) { + if (node.kind !== 259 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); } break; - case 157 /* OverrideKeyword */: + case 158 /* 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"); @@ -83651,7 +85439,7 @@ 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 === 260 /* ModuleBlock */ || node.parent.kind === 300 /* SourceFile */) { + else if (node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 303 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -83677,10 +85465,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 === 260 /* ModuleBlock */ || node.parent.kind === 300 /* SourceFile */) { + else if (node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 303 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 162 /* Parameter */) { + else if (node.kind === 163 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -83692,11 +85480,11 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 143 /* ReadonlyKeyword */: + case 144 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 165 /* PropertyDeclaration */ && node.kind !== 164 /* PropertySignature */ && node.kind !== 174 /* IndexSignature */ && node.kind !== 162 /* Parameter */) { + else if (node.kind !== 166 /* PropertyDeclaration */ && node.kind !== 165 /* PropertySignature */ && node.kind !== 175 /* IndexSignature */ && node.kind !== 163 /* 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); } @@ -83719,14 +85507,14 @@ 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 === 162 /* Parameter */) { + else if (node.kind === 163 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 88 /* DefaultKeyword */: - var container = node.parent.kind === 300 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 259 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 303 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 260 /* 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 */)) { @@ -83734,7 +85522,7 @@ var ts; } flags |= 512 /* Default */; break; - case 134 /* DeclareKeyword */: + case 135 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } @@ -83747,10 +85535,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 === 162 /* Parameter */) { + else if (node.kind === 163 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 260 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 261 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { @@ -83763,15 +85551,15 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - 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 */) { + if (node.kind !== 256 /* ClassDeclaration */ && + node.kind !== 179 /* ConstructorType */) { + if (node.kind !== 168 /* MethodDeclaration */ && + node.kind !== 166 /* PropertyDeclaration */ && + node.kind !== 171 /* GetAccessor */ && + node.kind !== 172 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 255 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 256 /* 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 */) { @@ -83792,14 +85580,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 130 /* AsyncKeyword */: + case 131 /* 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 === 162 /* Parameter */) { + else if (node.kind === 163 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } if (flags & 128 /* Abstract */) { @@ -83810,7 +85598,7 @@ var ts; break; } } - if (node.kind === 169 /* Constructor */) { + if (node.kind === 170 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -83828,13 +85616,13 @@ var ts; } return false; } - else if ((node.kind === 264 /* ImportDeclaration */ || node.kind === 263 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 265 /* ImportDeclaration */ || node.kind === 264 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 162 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 163 /* 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 === 162 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 163 /* 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 */) { @@ -83855,39 +85643,39 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - 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 */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 170 /* Constructor */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 175 /* IndexSignature */: + case 260 /* ModuleDeclaration */: + case 265 /* ImportDeclaration */: + case 264 /* ImportEqualsDeclaration */: + case 271 /* ExportDeclaration */: + case 270 /* ExportAssignment */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 163 /* Parameter */: return false; default: - if (node.parent.kind === 260 /* ModuleBlock */ || node.parent.kind === 300 /* SourceFile */) { + if (node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 303 /* SourceFile */) { return false; } switch (node.kind) { - case 254 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 130 /* AsyncKeyword */); - case 255 /* ClassDeclaration */: - case 178 /* ConstructorType */: + case 255 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); + case 256 /* ClassDeclaration */: + case 179 /* ConstructorType */: return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 256 /* InterfaceDeclaration */: - case 235 /* VariableStatement */: - case 257 /* TypeAliasDeclaration */: - case 168 /* ClassStaticBlockDeclaration */: + case 257 /* InterfaceDeclaration */: + case 236 /* VariableStatement */: + case 258 /* TypeAliasDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: return true; - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); default: ts.Debug.fail(); @@ -83899,10 +85687,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 167 /* MethodDeclaration */: - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 168 /* MethodDeclaration */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -83990,6 +85778,11 @@ var ts; if (!ts.isArrowFunction(node)) { return false; } + if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); + } + } var equalsGreaterThanToken = node.equalsGreaterThanToken; var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line; @@ -84060,7 +85853,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 === 225 /* OmittedExpression */) { + if (arg.kind === 226 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -84137,20 +85930,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 160 /* ComputedPropertyName */) { + if (node.kind !== 161 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 219 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 220 /* 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 === 254 /* FunctionDeclaration */ || - node.kind === 211 /* FunctionExpression */ || - node.kind === 167 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 255 /* FunctionDeclaration */ || + node.kind === 212 /* FunctionExpression */ || + node.kind === 168 /* MethodDeclaration */); if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -84169,7 +85962,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 === 293 /* SpreadAssignment */) { + if (prop.kind === 296 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -84180,11 +85973,11 @@ var ts; continue; } var name = prop.name; - if (name.kind === 160 /* ComputedPropertyName */) { + if (name.kind === 161 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 292 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 295 /* 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); @@ -84197,7 +85990,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 !== 130 /* AsyncKeyword */ || prop.kind !== 167 /* MethodDeclaration */) { + if (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 168 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -84212,10 +86005,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 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -84223,13 +86016,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 170 /* GetAccessor */: + case 171 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 171 /* SetAccessor */: + case 172 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -84269,7 +86062,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 === 285 /* JsxSpreadAttribute */) { + if (attr.kind === 286 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -84279,7 +86072,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 286 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 287 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -84314,7 +86107,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 242 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 243 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { @@ -84322,8 +86115,8 @@ var ts; if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.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)); } - if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4 /* ES2017 */) { - diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.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)); + if ((moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System && !(moduleKind === ts.ModuleKind.NodeNext && ts.getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ts.ModuleKind.ESNext)) || languageVersion < 4 /* ES2017 */) { + diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); } } } @@ -84332,7 +86125,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 !== 169 /* Constructor */) { + if (func && func.kind !== 170 /* 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); @@ -84349,7 +86142,7 @@ var ts; 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 */) { + if (forInOrOfStatement.initializer.kind === 254 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -84364,20 +86157,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 241 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 242 /* 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 === 241 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 242 /* 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 === 241 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 242 /* 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); @@ -84387,7 +86180,7 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 180 /* TypeLiteral */) && (accessor.parent.kind !== 256 /* InterfaceDeclaration */)) { + if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 181 /* TypeLiteral */) && (accessor.parent.kind !== 257 /* InterfaceDeclaration */)) { if (languageVersion < 1 /* ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } @@ -84402,7 +86195,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 === 180 /* TypeLiteral */ || accessor.parent.kind === 256 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 181 /* TypeLiteral */ || accessor.parent.kind === 257 /* InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -84410,11 +86203,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 170 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 171 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 171 /* SetAccessor */) { + if (accessor.kind === 172 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -84436,17 +86229,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 === 170 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 171 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 170 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 171 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 152 /* UniqueKeyword */) { - if (node.type.kind !== 149 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(149 /* SymbolKeyword */)); + if (node.operator === 153 /* UniqueKeyword */) { + if (node.type.kind !== 150 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(150 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -84457,7 +86250,7 @@ var ts; } } switch (parent.kind) { - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: var decl = parent; 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); @@ -84469,13 +86262,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 165 /* PropertyDeclaration */: + case 166 /* 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 164 /* PropertySignature */: + case 165 /* 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); } @@ -84484,9 +86277,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - 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 */)); + else if (node.operator === 144 /* ReadonlyKeyword */) { + if (node.type.kind !== 182 /* ArrayType */ && node.type.kind !== 183 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(150 /* SymbolKeyword */)); } } } @@ -84499,10 +86292,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 167 /* MethodDeclaration */) { - if (node.parent.kind === 203 /* ObjectLiteralExpression */) { + if (node.kind === 168 /* MethodDeclaration */) { + if (node.parent.kind === 204 /* 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 === 130 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -84531,14 +86324,14 @@ 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 === 167 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 168 /* 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 === 256 /* InterfaceDeclaration */) { + else if (node.parent.kind === 257 /* 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 === 180 /* TypeLiteral */) { + else if (node.parent.kind === 181 /* 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); } } @@ -84549,11 +86342,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 248 /* LabeledStatement */: + case 249 /* 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 === 243 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 244 /* 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); @@ -84561,8 +86354,8 @@ var ts; return false; } break; - case 247 /* SwitchStatement */: - if (node.kind === 244 /* BreakStatement */ && !node.label) { + case 248 /* SwitchStatement */: + if (node.kind === 245 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -84577,13 +86370,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 244 /* BreakStatement */ + var message = node.kind === 245 /* 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 === 244 /* BreakStatement */ + var message = node.kind === 245 /* 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); @@ -84607,12 +86400,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 217 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 218 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 217 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 218 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -84643,7 +86436,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 241 /* ForInStatement */ && node.parent.parent.kind !== 242 /* ForOfStatement */) { + if (node.parent.parent.kind !== 242 /* ForInStatement */ && node.parent.parent.kind !== 243 /* ForOfStatement */) { if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } @@ -84656,7 +86449,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 235 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 236 /* 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 @@ -84664,8 +86457,7 @@ var ts; : ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context; return grammarErrorOnNode(node.exclamationToken, message); } - var moduleKind = ts.getEmitModuleKind(compilerOptions); - if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System && + if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } @@ -84724,15 +86516,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 237 /* IfStatement */: - case 238 /* DoStatement */: - case 239 /* WhileStatement */: - case 246 /* WithStatement */: - case 240 /* ForStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: + case 238 /* IfStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: + case 247 /* WithStatement */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: return false; - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -84813,6 +86605,9 @@ var ts; } } function checkGrammarProperty(node) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); + } if (ts.isClassLike(node.parent)) { if (ts.isStringLiteral(node.name) && node.name.text === "constructor") { return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor); @@ -84824,7 +86619,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 === 256 /* InterfaceDeclaration */) { + else if (node.parent.kind === 257 /* 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; } @@ -84832,7 +86627,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 180 /* TypeLiteral */) { + else if (ts.isTypeLiteralNode(node.parent)) { 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; } @@ -84866,13 +86661,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - 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 */ || + if (node.kind === 257 /* InterfaceDeclaration */ || + node.kind === 258 /* TypeAliasDeclaration */ || + node.kind === 265 /* ImportDeclaration */ || + node.kind === 264 /* ImportEqualsDeclaration */ || + node.kind === 271 /* ExportDeclaration */ || + node.kind === 270 /* ExportAssignment */ || + node.kind === 263 /* NamespaceExportDeclaration */ || ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -84881,7 +86676,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 === 235 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 236 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -84904,7 +86699,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 === 233 /* Block */ || node.parent.kind === 260 /* ModuleBlock */ || node.parent.kind === 300 /* SourceFile */) { + if (node.parent.kind === 234 /* Block */ || node.parent.kind === 261 /* ModuleBlock */ || node.parent.kind === 303 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -84926,10 +86721,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, 194 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 195 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 294 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 297 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -84993,27 +86788,48 @@ var ts; return ambientModulesCache; } function checkGrammarImportClause(node) { + var _a; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamedImports */) { + return checkGrammarNamedImportsOrExports(node.namedBindings); + } return false; } + function checkGrammarNamedImportsOrExports(namedBindings) { + return !!ts.forEach(namedBindings.elements, function (specifier) { + if (specifier.isTypeOnly) { + return grammarErrorOnFirstToken(specifier, specifier.kind === 269 /* ImportSpecifier */ + ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement + : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); + } + }); + } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node12_or_nodenext); } if (node.typeArguments) { return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); } var nodeArguments = node.arguments; - if (nodeArguments.length !== 1) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument); + if (moduleKind !== ts.ModuleKind.ESNext) { + // We are allowed trailing comma after proposal-import-assertions. + checkGrammarForDisallowedTrailingComma(nodeArguments); + if (nodeArguments.length > 1) { + var assertionArgument = nodeArguments[1]; + return grammarErrorOnNode(assertionArgument, ts.Diagnostics.Dynamic_imports_only_support_a_second_argument_when_the_module_option_is_set_to_esnext); + } + } + if (nodeArguments.length === 0 || nodeArguments.length > 2) { + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments); } - checkGrammarForDisallowedTrailingComma(nodeArguments); // see: parseArgumentOrArrayLiteralElement...we use this function which parse arguments of callExpression to parse specifier for dynamic import. // parseArgumentOrArrayLiteralElement allows spread element to be in an argument list which is not allowed as specifier in dynamic import. - if (ts.isSpreadElement(nodeArguments[0])) { - return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element); + var spreadElement = ts.find(nodeArguments, ts.isSpreadElement); + if (spreadElement) { + return grammarErrorOnNode(spreadElement, ts.Diagnostics.Argument_of_dynamic_import_cannot_be_spread_element); } return false; } @@ -85108,14 +86924,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 254 /* FunctionDeclaration */ && declaration.kind !== 167 /* MethodDeclaration */) || + return (declaration.kind !== 255 /* FunctionDeclaration */ && declaration.kind !== 168 /* 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 268 /* ImportSpecifier */: - case 273 /* ExportSpecifier */: + case 269 /* ImportSpecifier */: + case 274 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -85365,7 +87181,7 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 158 /* LastToken */) || kind === 190 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 159 /* LastToken */) || kind === 191 /* ThisType */) { return node; } var factory = context.factory; @@ -85374,428 +87190,434 @@ var ts; case 79 /* Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 161 /* TypeParameter */: + case 162 /* 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 162 /* Parameter */: + case 163 /* 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 163 /* Decorator */: + case 164 /* Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 164 /* PropertySignature */: + case 165 /* 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 165 /* PropertyDeclaration */: + case 166 /* 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 166 /* MethodSignature */: + case 167 /* 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 167 /* MethodDeclaration */: + case 168 /* 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 169 /* Constructor */: + case 170 /* 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 170 /* GetAccessor */: + case 171 /* 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 171 /* SetAccessor */: + case 172 /* 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 168 /* ClassStaticBlockDeclaration */: + case 169 /* 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 */: + case 173 /* 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 173 /* ConstructSignature */: + case 174 /* 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 174 /* IndexSignature */: + case 175 /* 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 175 /* TypePredicate */: + case 176 /* 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 176 /* TypeReference */: + case 177 /* TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 177 /* FunctionType */: + case 178 /* 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 178 /* ConstructorType */: + case 179 /* 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 179 /* TypeQuery */: + case 180 /* TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); - case 180 /* TypeLiteral */: + case 181 /* TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 181 /* ArrayType */: + case 182 /* ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 182 /* TupleType */: + case 183 /* TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 183 /* OptionalType */: + case 184 /* OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 184 /* RestType */: + case 185 /* RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 185 /* UnionType */: + case 186 /* UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 186 /* IntersectionType */: + case 187 /* IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 187 /* ConditionalType */: + case 188 /* 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 188 /* InferType */: + case 189 /* InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 198 /* ImportType */: + case 199 /* 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 195 /* NamedTupleMember */: + case 196 /* 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 189 /* ParenthesizedType */: + case 190 /* ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 191 /* TypeOperator */: + case 192 /* TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 192 /* IndexedAccessType */: + case 193 /* IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 193 /* MappedType */: + case 194 /* 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 194 /* LiteralType */: + 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), nodesVisitor(node.members, visitor, ts.isTypeElement)); + case 195 /* LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 196 /* TemplateLiteralType */: + case 197 /* TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 197 /* TemplateLiteralTypeSpan */: + case 198 /* TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 199 /* ObjectBindingPattern */: + case 200 /* ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 200 /* ArrayBindingPattern */: + case 201 /* ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 201 /* BindingElement */: + case 202 /* 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 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 204 /* PropertyAccessExpression */: + case 205 /* 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 205 /* ElementAccessExpression */: + case 206 /* 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 206 /* CallExpression */: + case 207 /* 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 207 /* NewExpression */: + case 208 /* 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 208 /* TaggedTemplateExpression */: + case 209 /* 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 209 /* TypeAssertionExpression */: + case 210 /* TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 211 /* FunctionExpression */: + case 212 /* 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 212 /* ArrowFunction */: + case 213 /* 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 213 /* DeleteExpression */: + case 214 /* DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 214 /* TypeOfExpression */: + case 215 /* TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 215 /* VoidExpression */: + case 216 /* VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* AwaitExpression */: + case 217 /* AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 218 /* PostfixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 219 /* BinaryExpression */: + case 220 /* 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 220 /* ConditionalExpression */: + case 221 /* 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 221 /* TemplateExpression */: + case 222 /* TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 223 /* SpreadElement */: + case 224 /* SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 224 /* ClassExpression */: + case 225 /* 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 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 227 /* AsExpression */: + case 228 /* AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 228 /* NonNullExpression */: + case 229 /* 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 229 /* MetaProperty */: + case 230 /* MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 231 /* TemplateSpan */: + case 232 /* TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 233 /* Block */: + case 234 /* Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 237 /* IfStatement */: + case 238 /* 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 238 /* DoStatement */: + case 239 /* DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* WhileStatement */: + case 240 /* WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 240 /* ForStatement */: + case 241 /* 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 241 /* ForInStatement */: + case 242 /* 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 242 /* ForOfStatement */: + case 243 /* 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 243 /* ContinueStatement */: + case 244 /* ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 244 /* BreakStatement */: + case 245 /* BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 246 /* WithStatement */: + case 247 /* WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* ThrowStatement */: + case 250 /* ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 250 /* TryStatement */: + case 251 /* 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 252 /* VariableDeclaration */: + case 253 /* 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 253 /* VariableDeclarationList */: + case 254 /* VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 254 /* FunctionDeclaration */: + case 255 /* 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 255 /* ClassDeclaration */: + case 256 /* 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 256 /* InterfaceDeclaration */: + case 257 /* 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 257 /* TypeAliasDeclaration */: + case 258 /* 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 258 /* EnumDeclaration */: + case 259 /* 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 259 /* ModuleDeclaration */: + case 260 /* 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 260 /* ModuleBlock */: + case 261 /* ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 261 /* CaseBlock */: + case 262 /* CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 262 /* NamespaceExportDeclaration */: + case 263 /* NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 263 /* ImportEqualsDeclaration */: + case 264 /* 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 264 /* ImportDeclaration */: + case 265 /* 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), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); + case 292 /* AssertClause */: + ts.Debug.type(node); + return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); + case 293 /* AssertEntry */: 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 265 /* ImportClause */: + return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isStringLiteral)); + case 266 /* ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 266 /* NamespaceImport */: + case 267 /* NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 272 /* NamespaceExport */: + case 273 /* NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 267 /* NamedImports */: + case 268 /* NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 268 /* ImportSpecifier */: + case 269 /* ImportSpecifier */: ts.Debug.type(node); - return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* ExportAssignment */: + return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); + case 270 /* 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 270 /* ExportDeclaration */: + case 271 /* 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 271 /* NamedExports */: + 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), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); + case 272 /* NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 273 /* ExportSpecifier */: + case 274 /* ExportSpecifier */: ts.Debug.type(node); - return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); + return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 275 /* ExternalModuleReference */: + case 276 /* ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 276 /* JsxElement */: + case 277 /* 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 277 /* JsxSelfClosingElement */: + case 278 /* 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 278 /* JsxOpeningElement */: + case 279 /* 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 279 /* JsxClosingElement */: + case 280 /* JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 280 /* JsxFragment */: + case 281 /* 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 283 /* JsxAttribute */: + case 284 /* JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 284 /* JsxAttributes */: + case 285 /* JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 285 /* JsxSpreadAttribute */: + case 286 /* JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 286 /* JsxExpression */: + case 287 /* JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 287 /* CaseClause */: + case 288 /* CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 288 /* DefaultClause */: + case 289 /* DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 289 /* HeritageClause */: + case 290 /* HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 290 /* CatchClause */: + case 291 /* CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 293 /* SpreadAssignment */: + case 296 /* SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 294 /* EnumMember */: + case 297 /* 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 300 /* SourceFile */: + case 303 /* SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 345 /* PartiallyEmittedExpression */: + case 348 /* PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 346 /* CommaListExpression */: + case 349 /* CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -86100,7 +87922,7 @@ var ts; } 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=(.+)$/; + var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\r?\n?$/; var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/; function getLineInfo(text, lineStarts) { return { @@ -86486,7 +88308,7 @@ var ts; function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 300 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 303 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -86537,7 +88359,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -86550,13 +88372,13 @@ var ts; hasImportDefault = true; } break; - case 263 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 275 /* ExternalModuleReference */) { + case 264 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 276 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -86587,13 +88409,13 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -86601,7 +88423,7 @@ var ts; } } break; - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default function() { } @@ -86621,7 +88443,7 @@ var ts; } } break; - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default class { } @@ -86804,7 +88626,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 165 /* PropertyDeclaration */ + return member.kind === 166 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -87416,8 +89238,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(204 /* PropertyAccessExpression */); - context.enableSubstitution(205 /* ElementAccessExpression */); + context.enableSubstitution(205 /* PropertyAccessExpression */); + context.enableSubstitution(206 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -87443,14 +89265,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 301 /* Bundle */) { + if (node.kind === 304 /* 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 === 303 /* InputFiles */) { + if (prepend.kind === 306 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -87501,16 +89323,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 300 /* SourceFile */: - case 261 /* CaseBlock */: - case 260 /* ModuleBlock */: - case 233 /* Block */: + case 303 /* SourceFile */: + case 262 /* CaseBlock */: + case 261 /* ModuleBlock */: + case 234 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 255 /* ClassDeclaration */: - case 254 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: + case 255 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { break; } @@ -87522,7 +89344,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 === 255 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 256 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -87565,10 +89387,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 264 /* ImportDeclaration */: - case 263 /* ImportEqualsDeclaration */: - case 269 /* ExportAssignment */: - case 270 /* ExportDeclaration */: + case 265 /* ImportDeclaration */: + case 264 /* ImportEqualsDeclaration */: + case 270 /* ExportAssignment */: + case 271 /* ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -87589,13 +89411,13 @@ var ts; return node; } switch (node.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return visitImportDeclaration(node); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: return visitExportAssignment(node); - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -87615,11 +89437,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 270 /* ExportDeclaration */ || - node.kind === 264 /* ImportDeclaration */ || - node.kind === 265 /* ImportClause */ || - (node.kind === 263 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 275 /* ExternalModuleReference */)) { + if (node.kind === 271 /* ExportDeclaration */ || + node.kind === 265 /* ImportDeclaration */ || + node.kind === 266 /* ImportClause */ || + (node.kind === 264 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 276 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -87643,20 +89465,20 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 169 /* Constructor */: + case 170 /* Constructor */: return visitConstructor(node); - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 174 /* IndexSignature */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 167 /* MethodDeclaration */: - case 168 /* ClassStaticBlockDeclaration */: + case 175 /* IndexSignature */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 232 /* SemicolonClassElement */: + case 233 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -87691,64 +89513,64 @@ var ts; case 121 /* PrivateKeyword */: case 122 /* ProtectedKeyword */: case 126 /* AbstractKeyword */: - case 157 /* OverrideKeyword */: + case 158 /* OverrideKeyword */: case 85 /* ConstKeyword */: - case 134 /* DeclareKeyword */: - case 143 /* ReadonlyKeyword */: + case 135 /* DeclareKeyword */: + case 144 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - 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 182 /* ArrayType */: + case 183 /* TupleType */: + case 184 /* OptionalType */: + case 185 /* RestType */: + case 181 /* TypeLiteral */: + case 176 /* TypePredicate */: + case 162 /* TypeParameter */: + case 130 /* AnyKeyword */: + case 154 /* UnknownKeyword */: + case 133 /* BooleanKeyword */: + case 149 /* StringKeyword */: + case 146 /* NumberKeyword */: + case 143 /* 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 */: + case 150 /* SymbolKeyword */: + case 179 /* ConstructorType */: + case 178 /* FunctionType */: + case 180 /* TypeQuery */: + case 177 /* TypeReference */: + case 186 /* UnionType */: + case 187 /* IntersectionType */: + case 188 /* ConditionalType */: + case 190 /* ParenthesizedType */: + case 191 /* ThisType */: + case 192 /* TypeOperator */: + case 193 /* IndexedAccessType */: + case 194 /* MappedType */: + case 195 /* LiteralType */: // TypeScript type nodes are elided. // falls through - case 174 /* IndexSignature */: + case 175 /* IndexSignature */: // TypeScript index signatures are elided. // falls through - case 163 /* Decorator */: + case 164 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. return undefined; - case 257 /* TypeAliasDeclaration */: + case 258 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 165 /* PropertyDeclaration */: + case 166 /* 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 262 /* NamespaceExportDeclaration */: + case 263 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 169 /* Constructor */: + case 170 /* Constructor */: return visitConstructor(node); - case 256 /* InterfaceDeclaration */: + case 257 /* 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 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -87758,7 +89580,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 224 /* ClassExpression */: + case 225 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -87768,35 +89590,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 289 /* HeritageClause */: + case 290 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 170 /* GetAccessor */: + case 171 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 171 /* SetAccessor */: + case 172 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 162 /* Parameter */: + case 163 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -87806,40 +89628,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 209 /* TypeAssertionExpression */: - case 227 /* AsExpression */: + case 210 /* TypeAssertionExpression */: + case 228 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return visitCallExpression(node); - case 207 /* NewExpression */: + case 208 /* NewExpression */: return visitNewExpression(node); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 228 /* NonNullExpression */: + case 229 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 277 /* JsxSelfClosingElement */: + case 278 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 278 /* JsxOpeningElement */: + case 279 /* JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -88233,12 +90055,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -88391,7 +90213,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 165 /* PropertyDeclaration */ + ? member.kind === 166 /* 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() @@ -88519,10 +90341,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 167 /* MethodDeclaration */ - || kind === 170 /* GetAccessor */ - || kind === 171 /* SetAccessor */ - || kind === 165 /* PropertyDeclaration */; + return kind === 168 /* MethodDeclaration */ + || kind === 171 /* GetAccessor */ + || kind === 172 /* SetAccessor */ + || kind === 166 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -88532,7 +90354,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 167 /* MethodDeclaration */; + return node.kind === 168 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -88543,12 +90365,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return true; } return false; @@ -88565,15 +90387,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 165 /* PropertyDeclaration */: - case 162 /* Parameter */: + case 166 /* PropertyDeclaration */: + case 163 /* Parameter */: return serializeTypeNode(node.type); - case 171 /* SetAccessor */: - case 170 /* GetAccessor */: + case 172 /* SetAccessor */: + case 171 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: - case 167 /* MethodDeclaration */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 168 /* MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -88610,7 +90432,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 170 /* GetAccessor */) { + if (container && node.kind === 171 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -88656,30 +90478,30 @@ var ts; } switch (node.kind) { case 114 /* VoidKeyword */: - case 151 /* UndefinedKeyword */: - case 142 /* NeverKeyword */: + case 152 /* UndefinedKeyword */: + case 143 /* NeverKeyword */: return factory.createVoidZero(); - case 189 /* ParenthesizedType */: + case 190 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 177 /* FunctionType */: - case 178 /* ConstructorType */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: return factory.createIdentifier("Function"); - case 181 /* ArrayType */: - case 182 /* TupleType */: + case 182 /* ArrayType */: + case 183 /* TupleType */: return factory.createIdentifier("Array"); - case 175 /* TypePredicate */: - case 132 /* BooleanKeyword */: + case 176 /* TypePredicate */: + case 133 /* BooleanKeyword */: return factory.createIdentifier("Boolean"); - case 148 /* StringKeyword */: + case 149 /* StringKeyword */: return factory.createIdentifier("String"); - case 146 /* ObjectKeyword */: + case 147 /* ObjectKeyword */: return factory.createIdentifier("Object"); - case 194 /* LiteralType */: + case 195 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return factory.createIdentifier("Number"); case 9 /* BigIntLiteral */: @@ -88692,45 +90514,45 @@ var ts; default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 145 /* NumberKeyword */: + case 146 /* NumberKeyword */: return factory.createIdentifier("Number"); - case 156 /* BigIntKeyword */: + case 157 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 149 /* SymbolKeyword */: + case 150 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 176 /* TypeReference */: + case 177 /* TypeReference */: return serializeTypeReferenceNode(node); - case 186 /* IntersectionType */: - case 185 /* UnionType */: + case 187 /* IntersectionType */: + case 186 /* UnionType */: return serializeTypeList(node.types); - case 187 /* ConditionalType */: + case 188 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 191 /* TypeOperator */: - if (node.operator === 143 /* ReadonlyKeyword */) { + case 192 /* TypeOperator */: + if (node.operator === 144 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 179 /* TypeQuery */: - case 192 /* IndexedAccessType */: - case 193 /* MappedType */: - case 180 /* TypeLiteral */: - case 129 /* AnyKeyword */: - case 153 /* UnknownKeyword */: - case 190 /* ThisType */: - case 198 /* ImportType */: + case 180 /* TypeQuery */: + case 193 /* IndexedAccessType */: + case 194 /* MappedType */: + case 181 /* TypeLiteral */: + case 130 /* AnyKeyword */: + case 154 /* UnknownKeyword */: + case 191 /* ThisType */: + case 199 /* ImportType */: break; // handle JSDoc types from an invalid parse - case 307 /* JSDocAllType */: - case 308 /* JSDocUnknownType */: - case 312 /* JSDocFunctionType */: - case 313 /* JSDocVariadicType */: - case 314 /* JSDocNamepathType */: + case 310 /* JSDocAllType */: + case 311 /* JSDocUnknownType */: + case 315 /* JSDocFunctionType */: + case 316 /* JSDocVariadicType */: + case 317 /* JSDocNamepathType */: break; - case 309 /* JSDocNullableType */: - case 310 /* JSDocNonNullableType */: - case 311 /* JSDocOptionalType */: + case 312 /* JSDocNullableType */: + case 313 /* JSDocNonNullableType */: + case 314 /* JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -88743,13 +90565,13 @@ var ts; var serializedUnion; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 189 /* ParenthesizedType */) { + while (typeNode.kind === 190 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 142 /* NeverKeyword */) { + if (typeNode.kind === 143 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 194 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 151 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 195 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 152 /* 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); @@ -88859,7 +90681,7 @@ var ts; name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -89392,6 +91214,7 @@ var ts; || (isExternalModuleExport(node) && moduleKind !== ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.ES2020 + && moduleKind !== ts.ModuleKind.ES2022 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System); } @@ -89432,12 +91255,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 === 300 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 303 /* 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 === 258 /* EnumDeclaration */) { + if (node.kind === 259 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -89562,7 +91385,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 260 /* ModuleBlock */) { + if (node.body.kind === 261 /* ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -89609,19 +91432,19 @@ 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 !== 260 /* ModuleBlock */) { + if (!node.body || node.body.kind !== 261 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 259 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 260 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } /** - * Visits an import declaration, eliding it if it is not referenced and `importsNotUsedAsValues` is not 'preserve'. + * Visits an import declaration, eliding it if it is type-only or if it has an import clause that may be elided. * * @param node The import declaration node. */ @@ -89642,47 +91465,46 @@ var ts; compilerOptions.importsNotUsedAsValues === 2 /* Error */ ? factory.updateImportDeclaration(node, /*decorators*/ undefined, - /*modifiers*/ undefined, importClause, node.moduleSpecifier) + /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) : undefined; } /** - * Visits an import clause, eliding it if it is not referenced. + * Visits an import clause, eliding it if its `name` and `namedBindings` may both be elided. * * @param node The import clause node. */ function visitImportClause(node) { - if (node.isTypeOnly) { - return undefined; - } + ts.Debug.assert(!node.isTypeOnly); // Elide the import clause if we elide both its name and its named bindings. - var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + var name = shouldEmitAliasDeclaration(node) ? node.name : undefined; var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings); return (name || namedBindings) ? factory.updateImportClause(node, /*isTypeOnly*/ false, name, namedBindings) : undefined; } /** - * Visits named import bindings, eliding it if it is not referenced. + * Visits named import bindings, eliding them if their targets, their references, and the compilation settings allow. * * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 266 /* NamespaceImport */) { + if (node.kind === 267 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + return shouldEmitAliasDeclaration(node) ? node : undefined; } else { - // Elide named imports if all of its import specifiers are elided. + // Elide named imports if all of its import specifiers are elided and settings allow. + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); - return ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; + return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } } /** - * Visits an import specifier, eliding it if it is not referenced. + * Visits an import specifier, eliding it if its target, its references, and the compilation settings allow. * * @param node The import specifier node. */ function visitImportSpecifier(node) { - // Elide an import specifier if it is not referenced. - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + return !node.isTypeOnly && shouldEmitAliasDeclaration(node) ? node : undefined; } /** * Visits an export assignment, eliding it if it does not contain a clause that resolves @@ -89697,8 +91519,7 @@ var ts; : undefined; } /** - * Visits an export declaration, eliding it if it does not contain a clause that resolves - * to a value. + * Visits an export declaration, eliding it if it does not contain a clause that resolves to a value. * * @param node The export declaration node. */ @@ -89712,16 +91533,14 @@ var ts; // type checker doesn't know about any exports return node; } - if (!resolver.isValueAliasDeclaration(node)) { - // Elide the export declaration if it does not export a value. - return undefined; - } // Elide the export declaration if all of its named exports are elided. - var exportClause = ts.visitNode(node.exportClause, visitNamedExportBindings, ts.isNamedExportBindings); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, /*decorators*/ undefined, - /*modifiers*/ undefined, node.isTypeOnly, exportClause, node.moduleSpecifier) + /*modifiers*/ undefined, node.isTypeOnly, exportClause, node.moduleSpecifier, node.assertClause) : undefined; } /** @@ -89730,16 +91549,16 @@ var ts; * * @param node The named exports node. */ - function visitNamedExports(node) { + function visitNamedExports(node, allowEmpty) { // Elide the named exports if all of its export specifiers were elided. var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier); - return ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined; + return allowEmpty || ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined; } function visitNamespaceExports(node) { return factory.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier)); } - function visitNamedExportBindings(node) { - return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node); + function visitNamedExportBindings(node, allowEmpty) { + return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node, allowEmpty); } /** * Visits an export specifier, eliding it if it does not resolve to a value. @@ -89748,7 +91567,7 @@ var ts; */ function visitExportSpecifier(node) { // Elide an export specifier if it does not reference a value. - return resolver.isValueAliasDeclaration(node) ? node : undefined; + return !node.isTypeOnly && resolver.isValueAliasDeclaration(node) ? node : undefined; } /** * Determines whether to emit an import equals declaration. @@ -89759,7 +91578,7 @@ var ts; // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when // - current file is not external module // - import declaration is top level and target is value imported by entity name - return resolver.isReferencedAliasDeclaration(node) + return shouldEmitAliasDeclaration(node) || (!ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportEqualsWithEntityName(node)); } @@ -89774,13 +91593,14 @@ var ts; return undefined; } if (ts.isExternalModuleImportEqualsDeclaration(node)) { - var isReferenced = resolver.isReferencedAliasDeclaration(node); + var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*importClause*/ undefined, node.moduleReference.expression), node), node); + /*importClause*/ undefined, node.moduleReference.expression, + /*assertClause*/ undefined), node), node); } return isReferenced ? ts.visitEachChild(node, visitor, context) : undefined; } @@ -89918,16 +91738,16 @@ var ts; // 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(79 /* Identifier */); - context.enableSubstitution(292 /* ShorthandPropertyAssignment */); + context.enableSubstitution(295 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(259 /* ModuleDeclaration */); + context.enableEmitNotification(260 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 259 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 258 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 259 /* EnumDeclaration */; } /** * Hook for node emit. @@ -89988,9 +91808,9 @@ var ts; switch (node.kind) { case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -90028,9 +91848,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 !== 300 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 259 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 258 /* EnumDeclaration */); + if (container && container.kind !== 303 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 260 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 259 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -90068,6 +91888,11 @@ var ts; } return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined; } + function shouldEmitAliasDeclaration(node) { + return compilerOptions.preserveValueImports + ? resolver.isValueAliasDeclaration(node) + : resolver.isReferencedAliasDeclaration(node); + } } ts.transformTypeScript = transformTypeScript; })(ts || (ts = {})); @@ -90144,7 +91969,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && options.target === 99 /* ESNext */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -90154,16 +91979,16 @@ var ts; function visitorWorker(node, valueIsDiscarded) { if (node.transformFlags & 8388608 /* ContainsClassFields */) { switch (node.kind) { - case 224 /* ClassExpression */: - case 255 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 256 /* ClassDeclaration */: return visitClassLike(node); - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return visitVariableStatement(node); case 80 /* PrivateIdentifier */: return visitPrivateIdentifier(node); - case 168 /* ClassStaticBlockDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } @@ -90173,29 +91998,29 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 217 /* PrefixUnaryExpression */: - case 218 /* PostfixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return visitCallExpression(node); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: return visitExpressionStatement(node); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return visitForStatement(node); - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 169 /* Constructor */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: { + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 170 /* Constructor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -90214,17 +92039,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 289 /* HeritageClause */: + case 290 /* HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 203 /* ObjectLiteralExpression */: - case 202 /* ArrayLiteralExpression */: + case 204 /* ObjectLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -90232,14 +92057,37 @@ var ts; } /** * If we visit a private name, this means it is an undeclared private name. - * Replace it with an empty identifier to indicate a problem with the code. + * Replace it with an empty identifier to indicate a problem with the code, + * unless we are in a statement position - otherwise this will not trigger + * a SyntaxError. */ function visitPrivateIdentifier(node) { if (!shouldTransformPrivateElementsOrClassStaticBlocks) { return node; } + if (ts.isStatement(node.parent)) { + return node; + } return ts.setOriginalNode(factory.createIdentifier(""), node); } + /** + * Visits `#id in expr` + */ + function visitPrivateIdentifierInInExpression(node) { + if (!shouldTransformPrivateElementsOrClassStaticBlocks) { + return node; + } + var privId = node.left; + ts.Debug.assertNode(privId, ts.isPrivateIdentifier); + ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + var info = accessPrivateIdentifier(privId); + if (info) { + var receiver = ts.visitNode(node.right, visitor, ts.isExpression); + return ts.setOriginalNode(context.getEmitHelperFactory().createClassPrivateFieldInHelper(info.brandCheckIdentifier, receiver), node); + } + // Private name has not been declared. Subsequent transformers will handle this error + return ts.visitEachChild(node, visitor, context); + } /** * Visits the members of a class that has fields. * @@ -90247,19 +92095,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 169 /* Constructor */: + case 170 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 167 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 168 /* MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 232 /* SemicolonClassElement */: + case 233 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -90626,6 +92474,9 @@ var ts; } } } + if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + return visitPrivateIdentifierInInExpression(node); + } return ts.visitEachChild(node, visitor, context); } function createPrivateIdentifierAssignment(info, receiver, right, operator) { @@ -91084,17 +92935,17 @@ var ts; // 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 */); + context.enableEmitNotification(255 /* FunctionDeclaration */); + context.enableEmitNotification(212 /* FunctionExpression */); + context.enableEmitNotification(170 /* 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 */); + context.enableEmitNotification(171 /* GetAccessor */); + context.enableEmitNotification(172 /* SetAccessor */); + context.enableEmitNotification(168 /* MethodDeclaration */); + context.enableEmitNotification(166 /* PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(160 /* ComputedPropertyName */); + context.enableEmitNotification(161 /* ComputedPropertyName */); } } /** @@ -91133,13 +92984,13 @@ var ts; } } switch (node.kind) { - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { break; } // falls through - case 254 /* FunctionDeclaration */: - case 169 /* Constructor */: { + case 255 /* FunctionDeclaration */: + case 170 /* Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -91149,10 +93000,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 167 /* MethodDeclaration */: - case 165 /* PropertyDeclaration */: { + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 166 /* PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -91162,7 +93013,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 160 /* ComputedPropertyName */: { + case 161 /* ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -91672,34 +93523,34 @@ var ts; return node; } switch (node.kind) { - case 130 /* AsyncKeyword */: + case 131 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 216 /* AwaitExpression */: + case 217 /* AwaitExpression */: return visitAwaitExpression(node); - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 169 /* Constructor */: - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 170 /* Constructor */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -91708,27 +93559,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 242 /* ForOfStatement */: + case 243 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 290 /* CatchClause */: + case 291 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - 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 */: + case 234 /* Block */: + case 248 /* SwitchStatement */: + case 262 /* CaseBlock */: + case 288 /* CaseClause */: + case 289 /* DefaultClause */: + case 251 /* TryStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: + case 238 /* IfStatement */: + case 247 /* WithStatement */: + case 249 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -91933,7 +93784,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 === 212 /* ArrowFunction */; + var isArrowFunction = node.kind === 213 /* 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 @@ -92024,17 +93875,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(206 /* CallExpression */); - context.enableSubstitution(204 /* PropertyAccessExpression */); - context.enableSubstitution(205 /* ElementAccessExpression */); + context.enableSubstitution(207 /* CallExpression */); + context.enableSubstitution(205 /* PropertyAccessExpression */); + context.enableSubstitution(206 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(255 /* ClassDeclaration */); - context.enableEmitNotification(167 /* MethodDeclaration */); - context.enableEmitNotification(170 /* GetAccessor */); - context.enableEmitNotification(171 /* SetAccessor */); - context.enableEmitNotification(169 /* Constructor */); + context.enableEmitNotification(256 /* ClassDeclaration */); + context.enableEmitNotification(168 /* MethodDeclaration */); + context.enableEmitNotification(171 /* GetAccessor */); + context.enableEmitNotification(172 /* SetAccessor */); + context.enableEmitNotification(170 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(235 /* VariableStatement */); + context.enableEmitNotification(236 /* VariableStatement */); } } /** @@ -92082,11 +93933,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -92118,11 +93969,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 255 /* ClassDeclaration */ - || kind === 169 /* Constructor */ - || kind === 167 /* MethodDeclaration */ - || kind === 170 /* GetAccessor */ - || kind === 171 /* SetAccessor */; + return kind === 256 /* ClassDeclaration */ + || kind === 170 /* Constructor */ + || kind === 168 /* MethodDeclaration */ + || kind === 171 /* GetAccessor */ + || kind === 172 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -92279,7 +94130,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 130 /* AsyncKeyword */) { + if (node.kind === 131 /* AsyncKeyword */) { return undefined; } return node; @@ -92305,70 +94156,70 @@ var ts; return node; } switch (node.kind) { - case 216 /* AwaitExpression */: + case 217 /* AwaitExpression */: return visitAwaitExpression(node); - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: return visitYieldExpression(node); - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: return visitReturnStatement(node); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return visitLabeledStatement(node); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 346 /* CommaListExpression */: + case 349 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 290 /* CatchClause */: + case 291 /* CatchClause */: return visitCatchClause(node); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return visitVariableStatement(node); - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 238 /* DoStatement */: - case 239 /* WhileStatement */: - case 241 /* ForInStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: + case 242 /* ForInStatement */: return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 242 /* ForOfStatement */: + case 243 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 215 /* VoidExpression */: + case 216 /* VoidExpression */: return visitVoidExpression(node); - case 169 /* Constructor */: + case 170 /* Constructor */: return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 170 /* GetAccessor */: + case 171 /* GetAccessor */: return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 171 /* SetAccessor */: + case 172 /* SetAccessor */: return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 162 /* Parameter */: + case 163 /* Parameter */: return visitParameter(node); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: return visitExpressionStatement(node); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); @@ -92404,7 +94255,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 242 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 243 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -92416,7 +94267,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 === 293 /* SpreadAssignment */) { + if (e.kind === 296 /* SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -92425,7 +94276,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 291 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 294 /* PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -92459,7 +94310,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 !== 203 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 204 /* ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -92872,17 +94723,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(206 /* CallExpression */); - context.enableSubstitution(204 /* PropertyAccessExpression */); - context.enableSubstitution(205 /* ElementAccessExpression */); + context.enableSubstitution(207 /* CallExpression */); + context.enableSubstitution(205 /* PropertyAccessExpression */); + context.enableSubstitution(206 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(255 /* ClassDeclaration */); - context.enableEmitNotification(167 /* MethodDeclaration */); - context.enableEmitNotification(170 /* GetAccessor */); - context.enableEmitNotification(171 /* SetAccessor */); - context.enableEmitNotification(169 /* Constructor */); + context.enableEmitNotification(256 /* ClassDeclaration */); + context.enableEmitNotification(168 /* MethodDeclaration */); + context.enableEmitNotification(171 /* GetAccessor */); + context.enableEmitNotification(172 /* SetAccessor */); + context.enableEmitNotification(170 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(235 /* VariableStatement */); + context.enableEmitNotification(236 /* VariableStatement */); } } /** @@ -92930,11 +94781,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -92966,11 +94817,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 255 /* ClassDeclaration */ - || kind === 169 /* Constructor */ - || kind === 167 /* MethodDeclaration */ - || kind === 170 /* GetAccessor */ - || kind === 171 /* SetAccessor */; + return kind === 256 /* ClassDeclaration */ + || kind === 170 /* Constructor */ + || kind === 168 /* MethodDeclaration */ + || kind === 171 /* GetAccessor */ + || kind === 172 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -93002,7 +94853,7 @@ var ts; return node; } switch (node.kind) { - case 290 /* CatchClause */: + case 291 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -93034,25 +94885,25 @@ var ts; return node; } switch (node.kind) { - case 206 /* CallExpression */: { + case 207 /* CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* 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 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 213 /* DeleteExpression */: + case 214 /* DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -93094,7 +94945,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 204 /* PropertyAccessExpression */ + expression = node.kind === 205 /* 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; @@ -93117,10 +94968,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - 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); + case 211 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 207 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -93139,8 +94990,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -93150,11 +95001,11 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 204 /* PropertyAccessExpression */ + rightExpression = segment.kind === 205 /* PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 206 /* CallExpression */: + case 207 /* CallExpression */: if (i === 0 && leftThisArg) { rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } @@ -93211,7 +95062,7 @@ var ts; return node; } switch (node.kind) { - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -93289,11 +95140,11 @@ var ts; currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } - function getJsxFactoryCalleePrimitive(childrenLength) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : childrenLength > 1 ? "jsxs" : "jsx"; + function getJsxFactoryCalleePrimitive(isStaticChildren) { + return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } - function getJsxFactoryCallee(childrenLength) { - var type = getJsxFactoryCalleePrimitive(childrenLength); + function getJsxFactoryCallee(isStaticChildren) { + var type = getJsxFactoryCalleePrimitive(isStaticChildren); return getImplicitImportForName(type); } function getImplicitJsxFragmentReference() { @@ -93317,7 +95168,7 @@ var ts; currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); - var specifier = factory.createImportSpecifier(factory.createIdentifier(name), generatedName); + var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); return generatedName; @@ -93345,7 +95196,7 @@ var ts; var _b = _a[_i], importSource = _b[0], importSpecifiersMap = _b[1]; if (ts.isExternalModule(node)) { // Add `import` statement - var importStatement = factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause(/*typeOnly*/ false, /*name*/ undefined, factory.createNamedImports(ts.arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource)); + var importStatement = factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause(/*typeOnly*/ false, /*name*/ undefined, factory.createNamedImports(ts.arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource), /*assertClause*/ undefined); ts.setParentRecursive(importStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), importStatement); } @@ -93380,13 +95231,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 276 /* JsxElement */: + case 277 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 277 /* JsxSelfClosingElement */: + case 278 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 280 /* JsxFragment */: + case 281 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 286 /* JsxExpression */: + case 287 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -93396,13 +95247,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 286 /* JsxExpression */: + case 287 /* JsxExpression */: return visitJsxExpression(node); - case 276 /* JsxElement */: + case 277 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 277 /* JsxSelfClosingElement */: + case 278 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 280 /* JsxFragment */: + case 281 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -93440,60 +95291,37 @@ var ts; return tagTransform(node.openingFragment, node.children, isChild, /*location*/ node); } function convertJsxChildrenToChildrenPropObject(children) { + var prop = convertJsxChildrenToChildrenPropAssignment(children); + return prop && factory.createObjectLiteralExpression([prop]); + } + function convertJsxChildrenToChildrenPropAssignment(children) { var nonWhitespaceChildren = ts.getSemanticJsxChildren(children); - if (ts.length(nonWhitespaceChildren) === 1) { - var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]); - return result_13 && factory.createObjectLiteralExpression([ - factory.createPropertyAssignment("children", result_13) - ]); + if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) { + var result_12 = transformJsxChildToExpression(nonWhitespaceChildren[0]); + return result_12 && factory.createPropertyAssignment("children", result_12); } var result = ts.mapDefined(children, transformJsxChildToExpression); - return !result.length ? undefined : factory.createObjectLiteralExpression([ - factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) - ]); + return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined; } function visitJsxOpeningLikeElementJSX(node, children, isChild, location) { var tagName = getTagName(node); - var objectProperties; + var childrenProp = children && children.length ? convertJsxChildrenToChildrenPropAssignment(children) : undefined; var keyAttr = ts.find(node.attributes.properties, function (p) { return !!p.name && ts.isIdentifier(p.name) && p.name.escapedText === "key"; }); var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties; - var segments = []; - if (attrs.length) { - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - // We must always emit at least one object literal before a spread - // argument.factory.createObjectLiteral - segments.unshift(factory.createObjectLiteralExpression()); - } - } - if (children && children.length) { - var result = convertJsxChildrenToChildrenPropObject(children); - if (result) { - segments.push(result); - } - } - if (segments.length === 0) { - objectProperties = factory.createObjectLiteralExpression([]); - // When there are no attributes, React wants {} - } - else { - // Either emit one big object literal (no spread attribs), or - // a call to the __assign helper. - objectProperties = ts.singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments); - } - return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location); + var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) : + factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : ts.emptyArray); // When there are no attributes, React wants {} + return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, children || ts.emptyArray, isChild, location); } - function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) { + function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, children, isChild, location) { + var _a; + var nonWhitespaceChildren = ts.getSemanticJsxChildren(children); + var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken); var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)]; if (compilerOptions.jsx === 5 /* ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // isStaticChildren development flag - args.push(childrenLength > 1 ? factory.createTrue() : factory.createFalse()); + args.push(isStaticChildren ? factory.createTrue() : factory.createFalse()); // __source development flag var lineCol = ts.getLineAndCharacterOfPosition(originalFile, location.pos); args.push(factory.createObjectLiteralExpression([ @@ -93505,7 +95333,7 @@ var ts; args.push(factory.createThis()); } } - var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(childrenLength), /*typeArguments*/ undefined, args), location); + var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(isStaticChildren), /*typeArguments*/ undefined, args), location); if (isChild) { ts.startOnNewLine(element); } @@ -93513,38 +95341,9 @@ var ts; } function visitJsxOpeningLikeElementCreateElement(node, children, isChild, location) { var tagName = getTagName(node); - var objectProperties; var attrs = node.attributes.properties; - if (attrs.length === 0) { - objectProperties = factory.createNull(); - // When there are no attributes, React wants "null" - } - else { - var target = compilerOptions.target; - if (target && target >= 5 /* ES2018 */) { - objectProperties = factory.createObjectLiteralExpression(ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { - return isSpread ? ts.map(attrs, transformJsxSpreadAttributeToSpreadAssignment) : ts.map(attrs, transformJsxAttributeToObjectLiteralElement); - }))); - } - else { - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread - ? ts.map(attrs, transformJsxSpreadAttributeToExpression) - : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); - if (ts.isJsxSpreadAttribute(attrs[0])) { - // We must always emit at least one object literal before a spread - // argument.factory.createObjectLiteral - segments.unshift(factory.createObjectLiteralExpression()); - } - // Either emit one big object literal (no spread attribs), or - // a call to the __assign helper. - objectProperties = ts.singleOrUndefined(segments); - if (!objectProperties) { - objectProperties = emitHelpers().createAssignHelper(segments); - } - } - } + var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs) : + factory.createNull(); // When there are no attributes, React wants "null" var callee = currentFileState.importSpecifier === undefined ? ts.createJsxFactoryExpression(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 node) @@ -93564,7 +95363,7 @@ var ts; } } return visitJsxOpeningLikeElementOrFragmentJSX(getImplicitJsxFragmentReference(), childrenProps || factory.createObjectLiteralExpression([]), - /*keyAttr*/ undefined, ts.length(ts.getSemanticJsxChildren(children)), isChild, location); + /*keyAttr*/ undefined, children, isChild, location); } function visitJsxOpeningFragmentCreateElement(node, children, isChild, location) { var element = ts.createExpressionForJsxFragment(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), context.getEmitResolver().getJsxFragmentFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 @@ -93577,6 +95376,36 @@ var ts; function transformJsxSpreadAttributeToSpreadAssignment(node) { return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression)); } + function transformJsxAttributesToObjectProps(attrs, children) { + var target = ts.getEmitScriptTarget(compilerOptions); + return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + transformJsxAttributesToExpression(attrs, children); + } + function transformJsxAttributesToProps(attrs, children) { + var props = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { + return ts.map(attrs, function (attr) { return isSpread ? transformJsxSpreadAttributeToSpreadAssignment(attr) : transformJsxAttributeToObjectLiteralElement(attr); }); + })); + if (children) { + props.push(children); + } + return props; + } + function transformJsxAttributesToExpression(attrs, children) { + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + var expressions = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread + ? ts.map(attrs, transformJsxSpreadAttributeToExpression) + : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); })); + if (ts.isJsxSpreadAttribute(attrs[0])) { + // We must always emit at least one object literal before a spread + // argument.factory.createObjectLiteral + expressions.unshift(factory.createObjectLiteralExpression()); + } + if (children) { + expressions.push(factory.createObjectLiteralExpression([children])); + } + return ts.singleOrUndefined(expressions) || emitHelpers().createAssignHelper(expressions); + } function transformJsxSpreadAttributeToExpression(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } @@ -93596,7 +95425,7 @@ var ts; var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 286 /* JsxExpression */) { + else if (node.kind === 287 /* JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -93690,7 +95519,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 276 /* JsxElement */) { + if (node.kind === 277 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -93719,7 +95548,8 @@ var ts; } } function visitJsxExpression(node) { - return ts.visitNode(node.expression, visitor, ts.isExpression); + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return node.dotDotDotToken ? factory.createSpreadElement(expression) : expression; } } ts.transformJsx = transformJsx; @@ -93996,7 +95826,7 @@ var ts; return node; } switch (node.kind) { - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -94221,7 +96051,7 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 245 /* ReturnStatement */ + && node.kind === 246 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { @@ -94275,65 +96105,65 @@ var ts; switch (node.kind) { case 124 /* StaticKeyword */: return undefined; // elide static keyword - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: return visitClassDeclaration(node); - case 224 /* ClassExpression */: + case 225 /* ClassExpression */: return visitClassExpression(node); - case 162 /* Parameter */: + case 163 /* Parameter */: return visitParameter(node); - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return visitArrowFunction(node); - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: return visitFunctionExpression(node); - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return visitVariableDeclaration(node); case 79 /* Identifier */: return visitIdentifier(node); - case 253 /* VariableDeclarationList */: + case 254 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: return visitSwitchStatement(node); - case 261 /* CaseBlock */: + case 262 /* CaseBlock */: return visitCaseBlock(node); - case 233 /* Block */: + case 234 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 244 /* BreakStatement */: - case 243 /* ContinueStatement */: + case 245 /* BreakStatement */: + case 244 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return visitLabeledStatement(node); - case 238 /* DoStatement */: - case 239 /* WhileStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForOfStatement */: + case 243 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: return visitExpressionStatement(node); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 290 /* CatchClause */: + case 291 /* CatchClause */: return visitCatchClause(node); - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return visitCallExpression(node); - case 207 /* NewExpression */: + case 208 /* NewExpression */: return visitNewExpression(node); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 346 /* CommaListExpression */: + case 349 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -94344,30 +96174,30 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 221 /* TemplateExpression */: + case 222 /* TemplateExpression */: return visitTemplateExpression(node); - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: return visitYieldExpression(node); - case 223 /* SpreadElement */: + case 224 /* SpreadElement */: return visitSpreadElement(node); case 106 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 108 /* ThisKeyword */: return visitThisKeyword(node); - case 229 /* MetaProperty */: + case 230 /* MetaProperty */: return visitMetaProperty(node); - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return visitAccessorDeclaration(node); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return visitVariableStatement(node); - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: return visitReturnStatement(node); - case 215 /* VoidExpression */: + case 216 /* VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -94457,14 +96287,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 === 244 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 245 /* 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 === 244 /* BreakStatement */) { + if (node.kind === 245 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -94475,7 +96305,7 @@ var ts; } } else { - if (node.kind === 244 /* BreakStatement */) { + if (node.kind === 245 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -94873,11 +96703,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 245 /* ReturnStatement */) { + if (statement.kind === 246 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 237 /* IfStatement */) { + else if (statement.kind === 238 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -94885,7 +96715,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 233 /* Block */) { + else if (statement.kind === 234 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -95087,7 +96917,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 212 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 213 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -95109,22 +96939,22 @@ var ts; if (hierarchyFacts & 32768 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return statements; - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 169 /* Constructor */: + case 170 /* 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 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 212 /* 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 */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), @@ -95159,21 +96989,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 232 /* SemicolonClassElement */: + case 233 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 169 /* Constructor */: - case 168 /* ClassStaticBlockDeclaration */: + case 170 /* Constructor */: + case 169 /* ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -95373,7 +97203,7 @@ var ts; : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 254 /* FunctionDeclaration */ || node.kind === 211 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 255 /* FunctionDeclaration */ || node.kind === 212 /* FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -95419,7 +97249,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 212 /* ArrowFunction */); + ts.Debug.assert(node.kind === 213 /* 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 @@ -95726,14 +97556,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 238 /* DoStatement */: - case 239 /* WhileStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 242 /* ForOfStatement */: + case 243 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -95919,7 +97749,7 @@ var ts; var property = properties[i]; if ((property.transformFlags & 524288 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 160 /* ComputedPropertyName */)) { + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 161 /* ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -96035,11 +97865,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - 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); + case 241 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 242 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 243 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 239 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 240 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -96064,11 +97894,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 240 /* ForStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 253 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 254 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -96476,20 +98306,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -96596,7 +98426,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 170 /* GetAccessor */) { + if (node.kind === 171 /* GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -96991,78 +98821,17 @@ var ts; * @param node A TemplateExpression node. */ function visitTemplateExpression(node) { - var expressions = []; - addTemplateHead(expressions, node); - addTemplateSpans(expressions, node); - // createAdd will check if each expression binds less closely than binary '+'. - // If it does, it wraps the expression in parentheses. Otherwise, something like - // `abc${ 1 << 2 }` - // becomes - // "abc" + 1 << 2 + "" - // which is really - // ("abc" + 1) << (2 + "") - // rather than - // "abc" + (1 << 2) + "" - var expression = ts.reduceLeft(expressions, factory.createAdd); - if (ts.nodeIsSynthesized(expression)) { - ts.setTextRange(expression, node); - } - return expression; - } - /** - * Gets a value indicating whether we need to include the head of a TemplateExpression. - * - * @param node A TemplateExpression node. - */ - function shouldAddTemplateHead(node) { - // If this expression has an empty head literal and the first template span has a non-empty - // literal, then emitting the empty head literal is not necessary. - // `${ foo } and ${ bar }` - // can be emitted as - // foo + " and " + bar - // This is because it is only required that one of the first two operands in the emit - // output must be a string literal, so that the other operand and all following operands - // are forced into strings. - // - // If the first template span has an empty literal, then the head must still be emitted. - // `${ foo }${ bar }` - // must still be emitted as - // "" + foo + bar - // There is always atleast one templateSpan in this code path, since - // NoSubstitutionTemplateLiterals are directly emitted via emitLiteral() - ts.Debug.assert(node.templateSpans.length !== 0); - return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0; - } - /** - * Adds the head of a TemplateExpression to an array of expressions. - * - * @param expressions An array of expressions. - * @param node A TemplateExpression node. - */ - function addTemplateHead(expressions, node) { - if (!shouldAddTemplateHead(node)) { - return; - } - expressions.push(factory.createStringLiteral(node.head.text)); - } - /** - * Visits and adds the template spans of a TemplateExpression to an array of expressions. - * - * @param expressions An array of expressions. - * @param node A TemplateExpression node. - */ - function addTemplateSpans(expressions, node) { + var expression = factory.createStringLiteral(node.head.text); for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; - expressions.push(ts.visitNode(span.expression, visitor, ts.isExpression)); - // Only emit if the literal is non-empty. - // The binary '+' operator is left-associative, so the first string concatenation - // with the head will force the result up to this point to be a string. - // Emitting a '+ ""' has no semantic effect for middles and tails. - if (span.literal.text.length !== 0) { - expressions.push(factory.createStringLiteral(span.literal.text)); + var args = [ts.visitNode(span.expression, visitor, ts.isExpression)]; + if (span.literal.text.length > 0) { + args.push(factory.createStringLiteral(span.literal.text)); } + expression = factory.createCallExpression(factory.createPropertyAccessExpression(expression, "concat"), + /*typeArguments*/ undefined, args); } + return ts.setTextRange(expression, node); } /** * Visits the `super` keyword @@ -97117,13 +98886,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; 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 */); + context.enableEmitNotification(170 /* Constructor */); + context.enableEmitNotification(168 /* MethodDeclaration */); + context.enableEmitNotification(171 /* GetAccessor */); + context.enableEmitNotification(172 /* SetAccessor */); + context.enableEmitNotification(213 /* ArrowFunction */); + context.enableEmitNotification(212 /* FunctionExpression */); + context.enableEmitNotification(255 /* FunctionDeclaration */); } } /** @@ -97164,10 +98933,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 201 /* BindingElement */: - case 255 /* ClassDeclaration */: - case 258 /* EnumDeclaration */: - case 252 /* VariableDeclaration */: + case 202 /* BindingElement */: + case 256 /* ClassDeclaration */: + case 259 /* EnumDeclaration */: + case 253 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -97249,11 +99018,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 236 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 237 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 206 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 207 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -97261,7 +99030,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 223 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 224 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -97287,15 +99056,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(278 /* JsxOpeningElement */); - context.enableEmitNotification(279 /* JsxClosingElement */); - context.enableEmitNotification(277 /* JsxSelfClosingElement */); + context.enableEmitNotification(279 /* JsxOpeningElement */); + context.enableEmitNotification(280 /* JsxClosingElement */); + context.enableEmitNotification(278 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(204 /* PropertyAccessExpression */); - context.enableSubstitution(291 /* PropertyAssignment */); + context.enableSubstitution(205 /* PropertyAccessExpression */); + context.enableSubstitution(294 /* PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -97314,9 +99083,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 278 /* JsxOpeningElement */: - case 279 /* JsxClosingElement */: - case 277 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: + case 280 /* JsxClosingElement */: + case 278 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -97651,13 +99420,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 238 /* DoStatement */: + case 239 /* DoStatement */: return visitDoStatement(node); - case 239 /* WhileStatement */: + case 240 /* WhileStatement */: return visitWhileStatement(node); - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: return visitSwitchStatement(node); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -97670,24 +99439,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: return visitFunctionExpression(node); - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return visitAccessorDeclaration(node); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return visitForStatement(node); - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: return visitForInStatement(node); - case 244 /* BreakStatement */: + case 245 /* BreakStatement */: return visitBreakStatement(node); - case 243 /* ContinueStatement */: + case 244 /* ContinueStatement */: return visitContinueStatement(node); - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 524288 /* ContainsYield */) { @@ -97708,23 +99477,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return visitBinaryExpression(node); - case 346 /* CommaListExpression */: + case 349 /* CommaListExpression */: return visitCommaListExpression(node); - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: return visitConditionalExpression(node); - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: return visitYieldExpression(node); - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return visitCallExpression(node); - case 207 /* NewExpression */: + case 208 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -97737,9 +99506,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -97947,7 +99716,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -97959,7 +99728,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -98353,35 +100122,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 233 /* Block */: + case 234 /* Block */: return transformAndEmitBlock(node); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 237 /* IfStatement */: + case 238 /* IfStatement */: return transformAndEmitIfStatement(node); - case 238 /* DoStatement */: + case 239 /* DoStatement */: return transformAndEmitDoStatement(node); - case 239 /* WhileStatement */: + case 240 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return transformAndEmitForStatement(node); - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 243 /* ContinueStatement */: + case 244 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 244 /* BreakStatement */: + case 245 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 246 /* WithStatement */: + case 247 /* WithStatement */: return transformAndEmitWithStatement(node); - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 249 /* ThrowStatement */: + case 250 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 250 /* TryStatement */: + case 251 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -98811,7 +100580,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 288 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 289 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -98824,7 +100593,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 287 /* CaseClause */) { + if (clause.kind === 288 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -99984,12 +101753,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - 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(207 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(209 /* 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. + context.enableSubstitution(220 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(295 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(303 /* 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. @@ -100317,23 +102086,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return visitImportDeclaration(node); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: return visitExportDeclaration(node); - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: return visitExportAssignment(node); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return visitVariableStatement(node); - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: return visitClassDeclaration(node); - case 347 /* MergeDeclarationMarker */: + case 350 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 348 /* EndOfDeclarationMarker */: + case 351 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -100346,26 +102115,26 @@ var ts; return node; } switch (node.kind) { - case 240 /* ForStatement */: + case 241 /* ForStatement */: return visitForStatement(node); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: return visitExpressionStatement(node); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 345 /* PartiallyEmittedExpression */: + case 348 /* PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 206 /* CallExpression */: - if (ts.isImportCall(node)) { + case 207 /* CallExpression */: + if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 217 /* PrefixUnaryExpression */: - case 218 /* PostfixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -100381,24 +102150,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 293 /* SpreadAssignment */: + case 296 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -100578,7 +102347,7 @@ var ts; } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); - if (compilerOptions.esModuleInterop) { + if (ts.getESModuleInterop(compilerOptions)) { return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), /*typeArguments*/ undefined, [emitHelpers().createImportStarCallbackHelper()]); } return promise; @@ -100591,7 +102360,7 @@ var ts; // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); var requireCall = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); - if (compilerOptions.esModuleInterop) { + if (ts.getESModuleInterop(compilerOptions)) { requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; @@ -100621,7 +102390,7 @@ var ts; return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -100630,7 +102399,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -100784,7 +102553,7 @@ var ts; statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { - var exportNeedsImportDefault = !!compilerOptions.esModuleInterop && + var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); @@ -100986,7 +102755,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 235 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 236 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -101041,10 +102810,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 266 /* NamespaceImport */: + case 267 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 267 /* NamedImports */: + case 268 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -101257,7 +103026,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 300 /* SourceFile */) { + if (node.kind === 303 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -101319,11 +103088,11 @@ var ts; switch (node.kind) { case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return substituteCallExpression(node); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -101367,7 +103136,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 === 300 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 303 /* SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -101457,10 +103226,10 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; 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. + context.enableSubstitution(295 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(220 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(230 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(303 /* 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. @@ -101684,7 +103453,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 270 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 271 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -101774,19 +103543,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -101845,13 +103614,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return visitImportDeclaration(node); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: return visitExportDeclaration(node); - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -102031,7 +103800,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 === 300 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 303 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -102095,7 +103864,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 === 235 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 236 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -102157,10 +103926,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 266 /* NamespaceImport */: + case 267 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 267 /* NamedImports */: + case 268 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -102340,43 +104109,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return visitVariableStatement(node); - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: return visitClassDeclaration(node); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: return visitForInStatement(node); - case 242 /* ForOfStatement */: + case 243 /* ForOfStatement */: return visitForOfStatement(node); - case 238 /* DoStatement */: + case 239 /* DoStatement */: return visitDoStatement(node); - case 239 /* WhileStatement */: + case 240 /* WhileStatement */: return visitWhileStatement(node); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return visitLabeledStatement(node); - case 246 /* WithStatement */: + case 247 /* WithStatement */: return visitWithStatement(node); - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: return visitSwitchStatement(node); - case 261 /* CaseBlock */: + case 262 /* CaseBlock */: return visitCaseBlock(node); - case 287 /* CaseClause */: + case 288 /* CaseClause */: return visitCaseClause(node); - case 288 /* DefaultClause */: + case 289 /* DefaultClause */: return visitDefaultClause(node); - case 250 /* TryStatement */: + case 251 /* TryStatement */: return visitTryStatement(node); - case 290 /* CatchClause */: + case 291 /* CatchClause */: return visitCatchClause(node); - case 233 /* Block */: + case 234 /* Block */: return visitBlock(node); - case 347 /* MergeDeclarationMarker */: + case 350 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 348 /* EndOfDeclarationMarker */: + case 351 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -102562,26 +104331,26 @@ var ts; return node; } switch (node.kind) { - case 240 /* ForStatement */: + case 241 /* ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: return visitExpressionStatement(node); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 345 /* PartiallyEmittedExpression */: + case 348 /* PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 206 /* CallExpression */: + case 207 /* CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 217 /* PrefixUnaryExpression */: - case 218 /* PostfixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -102661,7 +104430,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 300 /* SourceFile */; + return container !== undefined && container.kind === 303 /* SourceFile */; } else { return false; @@ -102739,7 +104508,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 300 /* SourceFile */) { + if (node.kind === 303 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -102789,7 +104558,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -102826,9 +104595,9 @@ var ts; switch (node.kind) { case 79 /* Identifier */: return substituteExpressionIdentifier(node); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return substituteBinaryExpression(node); - case 229 /* MetaProperty */: + case 230 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -102918,7 +104687,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 300 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 303 /* SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -102953,21 +104722,32 @@ var ts; (function (ts) { function transformECMAScriptModule(context) { var factory = context.factory, emitHelpers = context.getEmitHelperFactory; + var host = context.getEmitHost(); + var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(300 /* SourceFile */); + context.enableEmitNotification(303 /* SourceFile */); context.enableSubstitution(79 /* Identifier */); var helperNameSubstitutions; + var currentSourceFile; + var importRequireStatements; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { + currentSourceFile = node; + importRequireStatements = undefined; var result = updateExternalModule(node); + currentSourceFile = undefined; + if (importRequireStatements) { + result = factory.updateSourceFile(result, ts.setTextRange(factory.createNodeArray(ts.insertStatementsAfterCustomPrologue(result.statements.slice(), importRequireStatements)), result.statements)); + } if (!ts.isExternalModule(node) || ts.some(result.statements, ts.isExternalModuleIndicator)) { return result; } @@ -102990,17 +104770,81 @@ var ts; } function visitor(node) { switch (node.kind) { - case 263 /* ImportEqualsDeclaration */: - // Elide `import=` as it is not legal with --module ES6 - return undefined; - case 269 /* ExportAssignment */: + case 264 /* ImportEqualsDeclaration */: + // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call + // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` + // is available, just because the output is reasonable for a node-like runtime. + return ts.getEmitScriptTarget(compilerOptions) >= ts.ModuleKind.ES2020 ? visitImportEqualsDeclaration(node) : undefined; + case 270 /* ExportAssignment */: return visitExportAssignment(node); - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } return node; } + /** + * Creates a `require()` call to import an external module. + * + * @param importNode The declaration to import. + */ + function createRequireCall(importNode) { + var moduleName = ts.getExternalModuleNameLiteral(factory, importNode, ts.Debug.checkDefined(currentSourceFile), host, resolver, compilerOptions); + var args = []; + if (moduleName) { + args.push(moduleName); + } + if (!importRequireStatements) { + var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var importStatement = factory.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, factory.createImportClause( + /*isTypeOnly*/ false, + /*name*/ undefined, factory.createNamedImports([ + factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) + ])), factory.createStringLiteral("module")); + var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireStatement = factory.createVariableStatement( + /*modifiers*/ undefined, factory.createVariableDeclarationList([ + factory.createVariableDeclaration(requireHelperName, + /*exclamationToken*/ undefined, + /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + ])) + ], + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + importRequireStatements = [importStatement, requireStatement]; + } + var name = importRequireStatements[1].declarationList.declarations[0].name; + ts.Debug.assertNode(name, ts.isIdentifier); + return factory.createCallExpression(factory.cloneNode(name), /*typeArguments*/ undefined, args); + } + /** + * Visits an ImportEqualsDeclaration node. + * + * @param node The node to visit. + */ + function visitImportEqualsDeclaration(node) { + ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + var statements; + statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( + /*modifiers*/ undefined, factory.createVariableDeclarationList([ + factory.createVariableDeclaration(factory.cloneNode(node.name), + /*exclamationToken*/ undefined, + /*type*/ undefined, createRequireCall(node)) + ], + /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + statements = appendExportsOfImportEqualsDeclaration(statements, node); + return ts.singleOrMany(statements); + } + function appendExportsOfImportEqualsDeclaration(statements, node) { + if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + statements = ts.append(statements, factory.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); + } + return statements; + } function visitExportAssignment(node) { // Elide `export=` as it is not legal with --module ES6 return node.isExportEquals ? undefined : node; @@ -103020,12 +104864,12 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause( /*isTypeOnly*/ false, - /*name*/ undefined, factory.createNamespaceImport(synthName)), node.moduleSpecifier); + /*name*/ undefined, factory.createNamespaceImport(synthName)), node.moduleSpecifier, node.assertClause); ts.setOriginalNode(importDecl, node.exportClause); var exportDecl = ts.isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(synthName, oldIdentifier)])); + /*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, synthName, oldIdentifier)])); ts.setOriginalNode(exportDecl, node); return [importDecl, exportDecl]; } @@ -103078,6 +104922,78 @@ var ts; } ts.transformECMAScriptModule = transformECMAScriptModule; })(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + function transformNodeModule(context) { + var previousOnSubstituteNode = context.onSubstituteNode; + var previousOnEmitNode = context.onEmitNode; + var esmTransform = ts.transformECMAScriptModule(context); + var esmOnSubstituteNode = context.onSubstituteNode; + var esmOnEmitNode = context.onEmitNode; + context.onSubstituteNode = previousOnSubstituteNode; + context.onEmitNode = previousOnEmitNode; + var cjsTransform = ts.transformModule(context); + var cjsOnSubstituteNode = context.onSubstituteNode; + var cjsOnEmitNode = context.onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(303 /* SourceFile */); + context.enableEmitNotification(303 /* SourceFile */); + var currentSourceFile; + return transformSourceFileOrBundle; + function onSubstituteNode(hint, node) { + if (ts.isSourceFile(node)) { + currentSourceFile = node; + // Neither component transform wants substitution notifications for `SourceFile`s, and, in fact, relies on + // the source file emit notification to setup scope variables for substitutions (so we _cannot_ call their substitute + // functions on source files safely, as that context only gets setup in a later pipeline phase!) + return previousOnSubstituteNode(hint, node); + } + else { + if (!currentSourceFile) { + return previousOnSubstituteNode(hint, node); + } + if (currentSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) { + return esmOnSubstituteNode(hint, node); + } + return cjsOnSubstituteNode(hint, node); + } + } + function onEmitNode(hint, node, emitCallback) { + if (ts.isSourceFile(node)) { + currentSourceFile = node; + } + if (!currentSourceFile) { + return previousOnEmitNode(hint, node, emitCallback); + } + if (currentSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) { + return esmOnEmitNode(hint, node, emitCallback); + } + return cjsOnEmitNode(hint, node, emitCallback); + } + function getModuleTransformForFile(file) { + return file.impliedNodeFormat === ts.ModuleKind.ESNext ? esmTransform : cjsTransform; + } + function transformSourceFile(node) { + if (node.isDeclarationFile) { + return node; + } + currentSourceFile = node; + var result = getModuleTransformForFile(node)(node); + currentSourceFile = undefined; + ts.Debug.assert(ts.isSourceFile(result)); + return result; + } + function transformSourceFileOrBundle(node) { + return node.kind === 303 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + } + function transformBundle(node) { + return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); + } + } + ts.transformNodeModule = transformNodeModule; +})(ts || (ts = {})); /* @internal */ var ts; (function (ts) { @@ -103130,7 +105046,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 255 /* ClassDeclaration */) { + else if (node.parent.kind === 256 /* 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 : @@ -103159,7 +105075,7 @@ var ts; 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 === 255 /* ClassDeclaration */) { + else if (node.parent.kind === 256 /* 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 : @@ -103206,7 +105122,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 === 252 /* VariableDeclaration */ || node.kind === 201 /* BindingElement */) { + if (node.kind === 253 /* VariableDeclaration */ || node.kind === 202 /* 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 : @@ -103215,8 +105131,8 @@ 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 === 165 /* PropertyDeclaration */ || node.kind === 204 /* PropertyAccessExpression */ || node.kind === 164 /* PropertySignature */ || - (node.kind === 162 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 166 /* PropertyDeclaration */ || node.kind === 205 /* PropertyAccessExpression */ || node.kind === 165 /* PropertySignature */ || + (node.kind === 163 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? @@ -103225,7 +105141,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 255 /* ClassDeclaration */ || node.kind === 162 /* Parameter */) { + else if (node.parent.kind === 256 /* ClassDeclaration */ || node.kind === 163 /* 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 : @@ -103250,7 +105166,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 171 /* SetAccessor */) { + if (node.kind === 172 /* 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.isStatic(node)) { @@ -103289,26 +105205,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 173 /* ConstructSignature */: + case 174 /* 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 172 /* CallSignature */: + case 173 /* 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 174 /* IndexSignature */: + case 175 /* 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 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -103316,7 +105232,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 255 /* ClassDeclaration */) { + else if (node.parent.kind === 256 /* 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 : @@ -103330,7 +105246,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 254 /* FunctionDeclaration */: + case 255 /* 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 : @@ -103355,30 +105271,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 169 /* Constructor */: + case 170 /* 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 173 /* ConstructSignature */: - case 178 /* ConstructorType */: + case 174 /* ConstructSignature */: + case 179 /* 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 172 /* CallSignature */: + case 173 /* 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 174 /* IndexSignature */: + case 175 /* 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 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -103386,7 +105302,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 255 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 256 /* 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 : @@ -103399,15 +105315,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 254 /* FunctionDeclaration */: - case 177 /* FunctionType */: + case 255 /* FunctionDeclaration */: + case 178 /* 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 171 /* SetAccessor */: - case 170 /* GetAccessor */: + case 172 /* SetAccessor */: + case 171 /* 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 : @@ -103421,39 +105337,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 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 256 /* InterfaceDeclaration */: + case 257 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 193 /* MappedType */: + case 194 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 178 /* ConstructorType */: - case 173 /* ConstructSignature */: + case 179 /* ConstructorType */: + case 174 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 172 /* CallSignature */: + case 173 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 168 /* MethodDeclaration */: + case 167 /* 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 === 255 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 256 /* 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 177 /* FunctionType */: - case 254 /* FunctionDeclaration */: + case 178 /* FunctionType */: + case 255 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 257 /* TypeAliasDeclaration */: + case 258 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -103519,7 +105435,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 162 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 163 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -103719,10 +105635,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 300 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 303 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 301 /* Bundle */) { + if (node.kind === 304 /* Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -103745,14 +105661,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(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*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([], [factory.createModifier(135 /* 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 === 303 /* InputFiles */) { + if (prepend.kind === 306 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -103892,7 +105808,7 @@ var ts; return name; } else { - if (name.kind === 200 /* ArrayBindingPattern */) { + if (name.kind === 201 /* ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -103900,7 +105816,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 225 /* OmittedExpression */) { + if (elem.kind === 226 /* OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -103938,19 +105854,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 162 /* Parameter */ && + var shouldUseResolverType = node.kind === 163 /* 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(129 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); } - if (node.kind === 171 /* SetAccessor */) { + if (node.kind === 172 /* 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(129 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -103958,12 +105874,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 252 /* VariableDeclaration */ || node.kind === 201 /* BindingElement */) { + if (node.kind === 253 /* VariableDeclaration */ || node.kind === 202 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 162 /* Parameter */ - || node.kind === 165 /* PropertyDeclaration */ - || node.kind === 164 /* PropertySignature */) { + if (node.kind === 163 /* Parameter */ + || node.kind === 166 /* PropertyDeclaration */ + || node.kind === 165 /* 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)); @@ -103974,28 +105890,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(129 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 254 /* FunctionDeclaration */: - case 259 /* ModuleDeclaration */: - case 256 /* InterfaceDeclaration */: - case 255 /* ClassDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 258 /* EnumDeclaration */: + case 255 /* FunctionDeclaration */: + case 260 /* ModuleDeclaration */: + case 257 /* InterfaceDeclaration */: + case 256 /* ClassDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 259 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 263 /* ImportEqualsDeclaration */: - case 264 /* ImportDeclaration */: - case 270 /* ExportDeclaration */: - case 269 /* ExportAssignment */: + case 264 /* ImportEqualsDeclaration */: + case 265 /* ImportDeclaration */: + case 271 /* ExportDeclaration */: + case 270 /* ExportAssignment */: return false; - case 168 /* ClassStaticBlockDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: return true; } return false; @@ -104085,7 +106001,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 259 /* ModuleDeclaration */ && parent.kind !== 198 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 260 /* ModuleDeclaration */ && parent.kind !== 199 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -104105,7 +106021,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 275 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 276 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -104123,31 +106039,34 @@ var ts; if (!decl.importClause) { // import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc) return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier)); + /*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), + /*assertClause*/ undefined); } // The `importClause` visibility corresponds to the default's visibility. var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined; if (!decl.importClause.namedBindings) { // No named bindings (either namespace or list), meaning the import is just default or should be elided return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, - /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); + /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), /*assertClause*/ undefined); } - if (decl.importClause.namedBindings.kind === 266 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 267 /* 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; + return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), /*assertClause*/ undefined) : undefined; } // Named imports (optionally with visible default) var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; }); if ((bindingList && bindingList.length) || visibleDefaultBinding) { return factory.updateImportDeclaration(decl, - /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); + /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), + /*assertClause*/ undefined); } // Augmentation of export depends on import if (resolver.isImportRequiredByAugmentation(decl)) { return factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, - /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier)); + /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), + /*assertClause*/ undefined); } // Nothing visible } @@ -104227,7 +106146,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 180 /* TypeLiteral */ || input.kind === 193 /* MappedType */) && input.parent.kind !== 257 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 181 /* TypeLiteral */ || input.kind === 194 /* MappedType */) && input.parent.kind !== 258 /* 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 */)) { @@ -104248,21 +106167,21 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 226 /* ExpressionWithTypeArguments */: { + case 227 /* 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 176 /* TypeReference */: { + case 177 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 173 /* ConstructSignature */: + case 174 /* ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 169 /* Constructor */: { + case 170 /* Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, @@ -104270,7 +106189,7 @@ var ts; /*body*/ undefined); return cleanup(ctor); } - case 167 /* MethodDeclaration */: { + case 168 /* MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -104280,7 +106199,7 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 170 /* GetAccessor */: { + case 171 /* GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -104289,7 +106208,7 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 171 /* SetAccessor */: { + case 172 /* SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -104297,31 +106216,31 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), /*body*/ undefined)); } - case 165 /* PropertyDeclaration */: + case 166 /* 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 164 /* PropertySignature */: + case 165 /* 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 166 /* MethodSignature */: { + case 167 /* 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 172 /* CallSignature */: { + case 173 /* CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* IndexSignature */: { + case 175 /* IndexSignature */: { return cleanup(factory.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(129 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); } - case 252 /* VariableDeclaration */: { + case 253 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -104329,13 +106248,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 161 /* TypeParameter */: { + case 162 /* 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 187 /* ConditionalType */: { + case 188 /* 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); @@ -104347,13 +106266,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 177 /* FunctionType */: { + case 178 /* FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 178 /* ConstructorType */: { + case 179 /* ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 198 /* ImportType */: { + case 199 /* 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)); @@ -104385,7 +106304,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 167 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 168 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -104395,7 +106314,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 270 /* ExportDeclaration */: { + case 271 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -104403,9 +106322,10 @@ var ts; // Always visible if the parent node isn't dropped for being not visible // Rewrite external module names if necessary return factory.updateExportDeclaration(input, - /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); + /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), + /*assertClause*/ undefined); } - case 269 /* ExportAssignment */: { + case 270 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -104423,7 +106343,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(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -104446,10 +106366,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 263 /* ImportEqualsDeclaration */: { + case 264 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 264 /* ImportDeclaration */: { + case 265 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -104470,14 +106390,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 257 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 258 /* 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 256 /* InterfaceDeclaration */: { + case 257 /* 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 254 /* FunctionDeclaration */: { + case 255 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -104516,7 +106436,7 @@ var ts; /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports(ts.map(exportMappings_1, function (_a) { var gen = _a[0], exp = _a[1]; - return factory.createExportSpecifier(gen, exp); + return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } var namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); @@ -104544,10 +106464,10 @@ var ts; return clean; } } - case 259 /* ModuleDeclaration */: { + case 260 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 260 /* ModuleBlock */) { + if (inner && inner.kind === 261 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -104590,7 +106510,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 255 /* ClassDeclaration */: { + case 256 /* ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -104655,7 +106575,7 @@ 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(134 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { if (clause.token === 94 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; @@ -104675,10 +106595,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 235 /* VariableStatement */: { + case 236 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 258 /* EnumDeclaration */: { + case 259 /* 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; @@ -104697,7 +106617,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 259 /* ModuleDeclaration */) { + if (input.kind === 260 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -104720,7 +106640,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 225 /* OmittedExpression */) { + if (e.kind === 226 /* OmittedExpression */) { return; } if (e.name) { @@ -104770,7 +106690,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 === 300 /* SourceFile */; + var parentIsFile = node.parent.kind === 303 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -104799,7 +106719,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 256 /* InterfaceDeclaration */) { + if (node.kind === 257 /* InterfaceDeclaration */) { return true; } return false; @@ -104824,7 +106744,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 170 /* GetAccessor */ + return accessor.kind === 171 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -104833,52 +106753,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 162 /* Parameter */: - case 252 /* VariableDeclaration */: + case 163 /* Parameter */: + case 253 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - 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 */: + case 255 /* FunctionDeclaration */: + case 260 /* ModuleDeclaration */: + case 264 /* ImportEqualsDeclaration */: + case 257 /* InterfaceDeclaration */: + case 256 /* ClassDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 259 /* EnumDeclaration */: + case 236 /* VariableStatement */: + case 265 /* ImportDeclaration */: + case 271 /* ExportDeclaration */: + case 270 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - 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 */: + case 174 /* ConstructSignature */: + case 170 /* Constructor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 167 /* MethodSignature */: + case 173 /* CallSignature */: + case 175 /* IndexSignature */: + case 253 /* VariableDeclaration */: + case 162 /* TypeParameter */: + case 227 /* ExpressionWithTypeArguments */: + case 177 /* TypeReference */: + case 188 /* ConditionalType */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: + case 199 /* ImportType */: return true; } return false; @@ -104890,11 +106810,15 @@ var ts; function getModuleTransformer(moduleKind) { switch (moduleKind) { case ts.ModuleKind.ESNext: + case ts.ModuleKind.ES2022: case ts.ModuleKind.ES2020: case ts.ModuleKind.ES2015: return ts.transformECMAScriptModule; case ts.ModuleKind.System: return ts.transformSystemModule; + case ts.ModuleKind.Node12: + case ts.ModuleKind.NodeNext: + return ts.transformNodeModule; default: return ts.transformModule; } @@ -105013,7 +106937,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(350 /* Count */); + var enabledSyntaxKindFeatures = new Array(353 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; @@ -105095,7 +107019,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 === 300 /* 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 === 303 /* 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(); } @@ -105501,11 +107425,11 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 301 /* Bundle */) { + if (sourceFile.kind === 304 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { - var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); + var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile.fileName, options)); var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && @@ -105521,26 +107445,13 @@ var ts; function getSourceMapFilePath(jsFilePath, options) { return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined; } - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve /* @internal */ - function getOutputExtension(sourceFile, options) { - if (ts.isJsonSourceFile(sourceFile)) { - return ".json" /* Json */; - } - if (options.jsx === 1 /* Preserve */) { - if (ts.isSourceFileJS(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx" /* Jsx */)) { - return ".jsx" /* Jsx */; - } - } - else if (sourceFile.languageVariant === 1 /* JSX */) { - // TypeScript source file preserving JSX syntax - return ".jsx" /* Jsx */; - } - } - return ".js" /* Js */; + function getOutputExtension(fileName, options) { + return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : + options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : + ".js" /* Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -105550,19 +107461,14 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(inputFileName, ".json" /* Json */)); - return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ".d.ts" /* Dts */); + return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ts.getDeclarationEmitExtensionForPath(inputFileName)); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); - var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ? - ".json" /* Json */ : - configFile.options.jsx === 1 /* Preserve */ && (ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) || ts.fileExtensionIs(inputFileName, ".jsx" /* Jsx */)) ? - ".jsx" /* Jsx */ : - ".js" /* Js */); + var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : undefined; @@ -105633,7 +107539,7 @@ var ts; /*@internal*/ function getCommonSourceDirectoryOfConfig(_a, ignoreCase) { var options = _a.options, fileNames = _a.fileNames; - return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensions)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); + return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensionsFlat)) && !ts.fileExtensionIs(file, ".d.ts" /* Dts */); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase)); } ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig; /*@internal*/ @@ -105868,7 +107774,7 @@ var ts; extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 300 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 303 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -105891,8 +107797,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 301 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 300 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 304 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 303 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -105933,7 +107839,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 300 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 303 /* 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 @@ -106244,9 +108150,9 @@ var ts; break; } switch (node.kind) { - case 300 /* SourceFile */: return printFile(node); - case 301 /* Bundle */: return printBundle(node); - case 302 /* UnparsedSource */: return printUnparsedSource(node); + case 303 /* SourceFile */: return printFile(node); + case 304 /* Bundle */: return printBundle(node); + case 305 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -106545,7 +108451,14 @@ var ts; // clear the parenthesizer rule as we ascend currentParenthesizerRule = undefined; } - function pipelineEmitWithHintWorker(hint, node) { + function pipelineEmitWithHintWorker(hint, node, allowSnippets) { + if (allowSnippets === void 0) { allowSnippets = true; } + if (allowSnippets) { + var snippet = ts.getSnippetElement(node); + if (snippet) { + return emitSnippetNode(hint, node, snippet); + } + } if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -106573,311 +108486,315 @@ var ts; return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: return emitQualifiedName(node); - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 161 /* TypeParameter */: + case 162 /* TypeParameter */: return emitTypeParameter(node); - case 162 /* Parameter */: + case 163 /* Parameter */: return emitParameter(node); - case 163 /* Decorator */: + case 164 /* Decorator */: return emitDecorator(node); // Type members - case 164 /* PropertySignature */: + case 165 /* PropertySignature */: return emitPropertySignature(node); - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 166 /* MethodSignature */: + case 167 /* MethodSignature */: return emitMethodSignature(node); - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 168 /* ClassStaticBlockDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 169 /* Constructor */: + case 170 /* Constructor */: return emitConstructor(node); - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return emitAccessorDeclaration(node); - case 172 /* CallSignature */: + case 173 /* CallSignature */: return emitCallSignature(node); - case 173 /* ConstructSignature */: + case 174 /* ConstructSignature */: return emitConstructSignature(node); - case 174 /* IndexSignature */: + case 175 /* IndexSignature */: return emitIndexSignature(node); // Types - case 175 /* TypePredicate */: + case 176 /* TypePredicate */: return emitTypePredicate(node); - case 176 /* TypeReference */: + case 177 /* TypeReference */: return emitTypeReference(node); - case 177 /* FunctionType */: + case 178 /* FunctionType */: return emitFunctionType(node); - case 178 /* ConstructorType */: + case 179 /* ConstructorType */: return emitConstructorType(node); - case 179 /* TypeQuery */: + case 180 /* TypeQuery */: return emitTypeQuery(node); - case 180 /* TypeLiteral */: + case 181 /* TypeLiteral */: return emitTypeLiteral(node); - case 181 /* ArrayType */: + case 182 /* ArrayType */: return emitArrayType(node); - case 182 /* TupleType */: + case 183 /* TupleType */: return emitTupleType(node); - case 183 /* OptionalType */: + case 184 /* OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 185 /* UnionType */: + case 186 /* UnionType */: return emitUnionType(node); - case 186 /* IntersectionType */: + case 187 /* IntersectionType */: return emitIntersectionType(node); - case 187 /* ConditionalType */: + case 188 /* ConditionalType */: return emitConditionalType(node); - case 188 /* InferType */: + case 189 /* InferType */: return emitInferType(node); - case 189 /* ParenthesizedType */: + case 190 /* ParenthesizedType */: return emitParenthesizedType(node); - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 190 /* ThisType */: + case 191 /* ThisType */: return emitThisType(); - case 191 /* TypeOperator */: + case 192 /* TypeOperator */: return emitTypeOperator(node); - case 192 /* IndexedAccessType */: + case 193 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 193 /* MappedType */: + case 194 /* MappedType */: return emitMappedType(node); - case 194 /* LiteralType */: + case 195 /* LiteralType */: return emitLiteralType(node); - case 195 /* NamedTupleMember */: + case 196 /* NamedTupleMember */: return emitNamedTupleMember(node); - case 196 /* TemplateLiteralType */: + case 197 /* TemplateLiteralType */: return emitTemplateType(node); - case 197 /* TemplateLiteralTypeSpan */: + case 198 /* TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 198 /* ImportType */: + case 199 /* ImportType */: return emitImportTypeNode(node); // Binding patterns - case 199 /* ObjectBindingPattern */: + case 200 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 200 /* ArrayBindingPattern */: + case 201 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 201 /* BindingElement */: + case 202 /* BindingElement */: return emitBindingElement(node); // Misc - case 231 /* TemplateSpan */: + case 232 /* TemplateSpan */: return emitTemplateSpan(node); - case 232 /* SemicolonClassElement */: + case 233 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 233 /* Block */: + case 234 /* Block */: return emitBlock(node); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return emitVariableStatement(node); - case 234 /* EmptyStatement */: + case 235 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: return emitExpressionStatement(node); - case 237 /* IfStatement */: + case 238 /* IfStatement */: return emitIfStatement(node); - case 238 /* DoStatement */: + case 239 /* DoStatement */: return emitDoStatement(node); - case 239 /* WhileStatement */: + case 240 /* WhileStatement */: return emitWhileStatement(node); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return emitForStatement(node); - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: return emitForInStatement(node); - case 242 /* ForOfStatement */: + case 243 /* ForOfStatement */: return emitForOfStatement(node); - case 243 /* ContinueStatement */: + case 244 /* ContinueStatement */: return emitContinueStatement(node); - case 244 /* BreakStatement */: + case 245 /* BreakStatement */: return emitBreakStatement(node); - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: return emitReturnStatement(node); - case 246 /* WithStatement */: + case 247 /* WithStatement */: return emitWithStatement(node); - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: return emitSwitchStatement(node); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: return emitLabeledStatement(node); - case 249 /* ThrowStatement */: + case 250 /* ThrowStatement */: return emitThrowStatement(node); - case 250 /* TryStatement */: + case 251 /* TryStatement */: return emitTryStatement(node); - case 251 /* DebuggerStatement */: + case 252 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 253 /* VariableDeclarationList */: + case 254 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: return emitClassDeclaration(node); - case 256 /* InterfaceDeclaration */: + case 257 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 257 /* TypeAliasDeclaration */: + case 258 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 260 /* ModuleBlock */: + case 261 /* ModuleBlock */: return emitModuleBlock(node); - case 261 /* CaseBlock */: + case 262 /* CaseBlock */: return emitCaseBlock(node); - case 262 /* NamespaceExportDeclaration */: + case 263 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return emitImportDeclaration(node); - case 265 /* ImportClause */: + case 266 /* ImportClause */: return emitImportClause(node); - case 266 /* NamespaceImport */: + case 267 /* NamespaceImport */: return emitNamespaceImport(node); - case 272 /* NamespaceExport */: + case 273 /* NamespaceExport */: return emitNamespaceExport(node); - case 267 /* NamedImports */: + case 268 /* NamedImports */: return emitNamedImports(node); - case 268 /* ImportSpecifier */: + case 269 /* ImportSpecifier */: return emitImportSpecifier(node); - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: return emitExportAssignment(node); - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: return emitExportDeclaration(node); - case 271 /* NamedExports */: + case 272 /* NamedExports */: return emitNamedExports(node); - case 273 /* ExportSpecifier */: + case 274 /* ExportSpecifier */: return emitExportSpecifier(node); - case 274 /* MissingDeclaration */: + case 292 /* AssertClause */: + return emitAssertClause(node); + case 293 /* AssertEntry */: + return emitAssertEntry(node); + case 275 /* MissingDeclaration */: return; // Module references - case 275 /* ExternalModuleReference */: + case 276 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 278 /* JsxOpeningElement */: - case 281 /* JsxOpeningFragment */: + case 279 /* JsxOpeningElement */: + case 282 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 279 /* JsxClosingElement */: - case 282 /* JsxClosingFragment */: + case 280 /* JsxClosingElement */: + case 283 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 283 /* JsxAttribute */: + case 284 /* JsxAttribute */: return emitJsxAttribute(node); - case 284 /* JsxAttributes */: + case 285 /* JsxAttributes */: return emitJsxAttributes(node); - case 285 /* JsxSpreadAttribute */: + case 286 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 286 /* JsxExpression */: + case 287 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 287 /* CaseClause */: + case 288 /* CaseClause */: return emitCaseClause(node); - case 288 /* DefaultClause */: + case 289 /* DefaultClause */: return emitDefaultClause(node); - case 289 /* HeritageClause */: + case 290 /* HeritageClause */: return emitHeritageClause(node); - case 290 /* CatchClause */: + case 291 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 293 /* SpreadAssignment */: + case 296 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 294 /* EnumMember */: + case 297 /* EnumMember */: return emitEnumMember(node); // Unparsed - case 295 /* UnparsedPrologue */: + case 298 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 302 /* UnparsedSource */: - case 296 /* UnparsedPrepend */: + case 305 /* UnparsedSource */: + case 299 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 297 /* UnparsedText */: - case 298 /* UnparsedInternalText */: + case 300 /* UnparsedText */: + case 301 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 299 /* UnparsedSyntheticReference */: + case 302 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 300 /* SourceFile */: + case 303 /* SourceFile */: return emitSourceFile(node); - case 301 /* Bundle */: + case 304 /* Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 303 /* InputFiles */: + case 306 /* InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 304 /* JSDocTypeExpression */: + case 307 /* JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 305 /* JSDocNameReference */: + case 308 /* JSDocNameReference */: return emitJSDocNameReference(node); - case 307 /* JSDocAllType */: + case 310 /* JSDocAllType */: return writePunctuation("*"); - case 308 /* JSDocUnknownType */: + case 311 /* JSDocUnknownType */: return writePunctuation("?"); - case 309 /* JSDocNullableType */: + case 312 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 310 /* JSDocNonNullableType */: + case 313 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 311 /* JSDocOptionalType */: + case 314 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 312 /* JSDocFunctionType */: + case 315 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 184 /* RestType */: - case 313 /* JSDocVariadicType */: + case 185 /* RestType */: + case 316 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 314 /* JSDocNamepathType */: + case 317 /* JSDocNamepathType */: return; - case 315 /* JSDocComment */: + case 318 /* JSDocComment */: return emitJSDoc(node); - case 317 /* JSDocTypeLiteral */: + case 320 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 318 /* JSDocSignature */: + case 321 /* JSDocSignature */: return emitJSDocSignature(node); - case 322 /* JSDocTag */: - case 327 /* JSDocClassTag */: + case 325 /* JSDocTag */: + case 330 /* JSDocClassTag */: return emitJSDocSimpleTag(node); - case 323 /* JSDocAugmentsTag */: - case 324 /* JSDocImplementsTag */: + case 326 /* JSDocAugmentsTag */: + case 327 /* JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 325 /* JSDocAuthorTag */: - case 326 /* JSDocDeprecatedTag */: + case 328 /* JSDocAuthorTag */: + case 329 /* JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 328 /* JSDocPublicTag */: - case 329 /* JSDocPrivateTag */: - case 330 /* JSDocProtectedTag */: - case 331 /* JSDocReadonlyTag */: - case 332 /* JSDocOverrideTag */: + case 331 /* JSDocPublicTag */: + case 332 /* JSDocPrivateTag */: + case 333 /* JSDocProtectedTag */: + case 334 /* JSDocReadonlyTag */: + case 335 /* JSDocOverrideTag */: return; - case 333 /* JSDocCallbackTag */: + case 336 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 335 /* JSDocParameterTag */: - case 342 /* JSDocPropertyTag */: + case 338 /* JSDocParameterTag */: + case 345 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 334 /* JSDocEnumTag */: - case 336 /* JSDocReturnTag */: - case 337 /* JSDocThisTag */: - case 338 /* JSDocTypeTag */: + case 337 /* JSDocEnumTag */: + case 339 /* JSDocReturnTag */: + case 340 /* JSDocThisTag */: + case 341 /* JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 339 /* JSDocTemplateTag */: + case 342 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 340 /* JSDocTypedefTag */: + case 343 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 341 /* JSDocSeeTag */: + case 344 /* JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 344 /* NotEmittedStatement */: - case 348 /* EndOfDeclarationMarker */: - case 347 /* MergeDeclarationMarker */: + case 347 /* NotEmittedStatement */: + case 351 /* EndOfDeclarationMarker */: + case 350 /* MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { @@ -106906,84 +108823,86 @@ var ts; // Identifiers case 79 /* Identifier */: return emitIdentifier(node); + case 80 /* PrivateIdentifier */: + return emitPrivateIdentifier(node); // Expressions - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return emitCallExpression(node); - case 207 /* NewExpression */: + case 208 /* NewExpression */: return emitNewExpression(node); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 209 /* TypeAssertionExpression */: + case 210 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: return emitFunctionExpression(node); - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return emitArrowFunction(node); - case 213 /* DeleteExpression */: + case 214 /* DeleteExpression */: return emitDeleteExpression(node); - case 214 /* TypeOfExpression */: + case 215 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 215 /* VoidExpression */: + case 216 /* VoidExpression */: return emitVoidExpression(node); - case 216 /* AwaitExpression */: + case 217 /* AwaitExpression */: return emitAwaitExpression(node); - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 218 /* PostfixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return emitBinaryExpression(node); - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: return emitConditionalExpression(node); - case 221 /* TemplateExpression */: + case 222 /* TemplateExpression */: return emitTemplateExpression(node); - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: return emitYieldExpression(node); - case 223 /* SpreadElement */: + case 224 /* SpreadElement */: return emitSpreadElement(node); - case 224 /* ClassExpression */: + case 225 /* ClassExpression */: return emitClassExpression(node); - case 225 /* OmittedExpression */: + case 226 /* OmittedExpression */: return; - case 227 /* AsExpression */: + case 228 /* AsExpression */: return emitAsExpression(node); - case 228 /* NonNullExpression */: + case 229 /* NonNullExpression */: return emitNonNullExpression(node); - case 229 /* MetaProperty */: + case 230 /* MetaProperty */: return emitMetaProperty(node); - case 230 /* SyntheticExpression */: + case 231 /* SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 276 /* JsxElement */: + case 277 /* JsxElement */: return emitJsxElement(node); - case 277 /* JsxSelfClosingElement */: + case 278 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 280 /* JsxFragment */: + case 281 /* JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 343 /* SyntaxList */: + case 346 /* SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 344 /* NotEmittedStatement */: + case 347 /* NotEmittedStatement */: return; - case 345 /* PartiallyEmittedExpression */: + case 348 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 346 /* CommaListExpression */: + case 349 /* CommaListExpression */: return emitCommaList(node); - case 347 /* MergeDeclarationMarker */: - case 348 /* EndOfDeclarationMarker */: + case 350 /* MergeDeclarationMarker */: + case 351 /* EndOfDeclarationMarker */: return; - case 349 /* SyntheticReferenceExpression */: + case 352 /* SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -107031,7 +108950,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 301 /* Bundle */ ? node : undefined; + var bundle = node.kind === 304 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -107131,7 +109050,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 297 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 300 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -107148,6 +109067,28 @@ var ts; } } // + // Snippet Elements + // + function emitSnippetNode(hint, node, snippet) { + switch (snippet.kind) { + case 1 /* Placeholder */: + emitPlaceholder(hint, node, snippet); + break; + case 0 /* TabStop */: + emitTabStop(snippet); + break; + } + } + function emitPlaceholder(hint, node, snippet) { + nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` + nonEscapingWrite("}"); // `}` + // `${2:...}` + } + function emitTabStop(snippet) { + nonEscapingWrite("$" + snippet.order); + } + // // Identifiers // function emitIdentifier(node) { @@ -107204,7 +109145,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 312 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 315 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -107272,7 +109213,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 170 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 171 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -107469,7 +109410,7 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 143 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 144 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); @@ -107702,7 +109643,7 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(131 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -107727,7 +109668,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 === 217 /* PrefixUnaryExpression */ + return operand.kind === 218 /* 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 */))); } @@ -107932,7 +109873,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 237 /* IfStatement */) { + if (node.elseStatement.kind === 238 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -107995,7 +109936,7 @@ var ts; emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(158 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(159 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -108003,7 +109944,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 253 /* VariableDeclarationList */) { + if (node.kind === 254 /* VariableDeclarationList */) { emit(node); } else { @@ -108040,7 +109981,7 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 286 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 287 /* JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; @@ -108318,7 +110259,7 @@ var ts; emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(151 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); @@ -108343,15 +110284,18 @@ var ts; if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(154 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(155 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); + if (node.assertClause) { + emitWithLeadingSpace(node.assertClause); + } writeTrailingSemicolon(); } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(150 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(151 /* TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); @@ -108393,7 +110337,7 @@ var ts; var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(150 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(151 /* TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { @@ -108405,18 +110349,39 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(154 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(155 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } + if (node.assertClause) { + emitWithLeadingSpace(node.assertClause); + } writeTrailingSemicolon(); } + function emitAssertClause(node) { + emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + writeSpace(); + var elements = node.elements; + emitList(node, elements, 526226 /* ImportClauseEntries */); + } + function emitAssertEntry(node) { + emit(node.name); + writePunctuation(":"); + writeSpace(); + var value = node.value; + /** @see {emitPropertyAssignment} */ + if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + var commentRange = ts.getCommentRange(value); + emitTrailingCommentsOfPosition(commentRange.pos); + } + emit(value); + } function emitNamespaceExportDeclaration(node) { var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(141 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -108440,6 +110405,10 @@ var ts; writePunctuation("}"); } function emitImportOrExportSpecifier(node) { + if (node.isTypeOnly) { + writeKeyword("type"); + writeSpace(); + } if (node.propertyName) { emit(node.propertyName); writeSpace(); @@ -108663,7 +110632,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 338 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 341 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -108708,7 +110677,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 304 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 307 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -108727,7 +110696,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 317 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 320 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -109358,6 +111327,15 @@ var ts; function writeProperty(s) { writer.writeProperty(s); } + function nonEscapingWrite(s) { + // This should be defined in a snippet-escaping text writer. + if (writer.nonEscapingWrite) { + writer.nonEscapingWrite(s); + } + else { + writer.write(s); + } + } function writeLine(count) { if (count === void 0) { count = 1; } for (var i = 0; i < count; i++) { @@ -109614,7 +111592,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 210 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 211 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -109684,84 +111662,84 @@ var ts; if (!node) return; switch (node.kind) { - case 233 /* Block */: + case 234 /* Block */: ts.forEach(node.statements, generateNames); break; - case 248 /* LabeledStatement */: - case 246 /* WithStatement */: - case 238 /* DoStatement */: - case 239 /* WhileStatement */: + case 249 /* LabeledStatement */: + case 247 /* WithStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: generateNames(node.statement); break; - case 237 /* IfStatement */: + case 238 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 240 /* ForStatement */: - case 242 /* ForOfStatement */: - case 241 /* ForInStatement */: + case 241 /* ForStatement */: + case 243 /* ForOfStatement */: + case 242 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 261 /* CaseBlock */: + case 262 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 287 /* CaseClause */: - case 288 /* DefaultClause */: + case 288 /* CaseClause */: + case 289 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 250 /* TryStatement */: + case 251 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 290 /* CatchClause */: + case 291 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: generateNames(node.declarationList); break; - case 253 /* VariableDeclarationList */: + case 254 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 252 /* VariableDeclaration */: - case 162 /* Parameter */: - case 201 /* BindingElement */: - case 255 /* ClassDeclaration */: + case 253 /* VariableDeclaration */: + case 163 /* Parameter */: + case 202 /* BindingElement */: + case 256 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 199 /* ObjectBindingPattern */: - case 200 /* ArrayBindingPattern */: + case 200 /* ObjectBindingPattern */: + case 201 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: generateNames(node.importClause); break; - case 265 /* ImportClause */: + case 266 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 266 /* NamespaceImport */: + case 267 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 272 /* NamespaceExport */: + case 273 /* NamespaceExport */: generateNameIfNeeded(node.name); break; - case 267 /* NamedImports */: + case 268 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 268 /* ImportSpecifier */: + case 269 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -109770,12 +111748,12 @@ var ts; if (!node) return; switch (node.kind) { - case 291 /* PropertyAssignment */: - case 292 /* ShorthandPropertyAssignment */: - case 165 /* PropertyDeclaration */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 294 /* PropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: + case 166 /* PropertyDeclaration */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -109957,23 +111935,23 @@ var ts; switch (node.kind) { case 79 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 259 /* ModuleDeclaration */: - case 258 /* EnumDeclaration */: + case 260 /* ModuleDeclaration */: + case 259 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 264 /* ImportDeclaration */: - case 270 /* ExportDeclaration */: + case 265 /* ImportDeclaration */: + case 271 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 254 /* FunctionDeclaration */: - case 255 /* ClassDeclaration */: - case 269 /* ExportAssignment */: + case 255 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: + case 270 /* ExportAssignment */: return generateNameForExportDefault(); - case 224 /* ClassExpression */: + case 225 /* ClassExpression */: return generateNameForClassExpression(); - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -110054,7 +112032,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 !== 344 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 347 /* 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. @@ -110065,7 +112043,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 === 253 /* VariableDeclarationList */) { + if (node.kind === 254 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -110084,7 +112062,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 !== 344 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 347 /* NotEmittedStatement */) { emitTrailingComments(end); } } @@ -110359,7 +112337,7 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 344 /* NotEmittedStatement */ + if (node.kind !== 347 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); @@ -110377,7 +112355,7 @@ var ts; if (emitFlags & 64 /* NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 344 /* NotEmittedStatement */ + if (node.kind !== 347 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); @@ -110627,7 +112605,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, directoryExists); + return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath); } return host.readDirectory(rootDir, extensions, excludes, includes, depth); function getFileSystemEntries(dir) { @@ -110868,7 +112846,7 @@ var ts; if (options.declarationDir) return false; } - else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.supportedJSExtensions)) { + else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.supportedJSExtensionsFlat)) { return false; } // just check if sourceFile with the name exists @@ -111480,6 +113458,56 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + ; + /* @internal */ + function getModeForResolutionAtIndex(file, index) { + if (file.impliedNodeFormat === undefined) + return undefined; + // we ensure all elements of file.imports and file.moduleAugmentations have the relevant parent pointers set during program setup, + // so it's safe to use them even pre-bind + return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index)); + } + ts.getModeForResolutionAtIndex = getModeForResolutionAtIndex; + /* @internal */ + function getModeForUsageLocation(file, usage) { + var _a; + if (file.impliedNodeFormat === undefined) + return undefined; + if (file.impliedNodeFormat !== ts.ModuleKind.ESNext) { + // in cjs files, import call expressions are esm format, otherwise everything is cjs + return ts.isImportCall(ts.walkUpParenthesizedExpressions(usage.parent)) ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + } + // in esm files, import=require statements are cjs format, otherwise everything is esm + // imports are only parent'd up to their containing declaration/expression, so access farther parents with care + var exprParentParent = (_a = ts.walkUpParenthesizedExpressions(usage.parent)) === null || _a === void 0 ? void 0 : _a.parent; + return exprParentParent && ts.isImportEqualsDeclaration(exprParentParent) ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext; + } + ts.getModeForUsageLocation = getModeForUsageLocation; + /* @internal */ + function loadWithModeAwareCache(names, containingFile, containingFileName, redirectedReference, loader) { + if (names.length === 0) { + return []; + } + var resolutions = []; + var cache = new ts.Map(); + var i = 0; + for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { + var name = names_3[_i]; + var result = void 0; + var mode = getModeForResolutionAtIndex(containingFile, i); + i++; + var cacheKey = mode !== undefined ? mode + "|" + name : name; + if (cache.has(cacheKey)) { + result = cache.get(cacheKey); + } + else { + cache.set(cacheKey, result = loader(name, mode, containingFileName, redirectedReference)); + } + resolutions.push(result); + } + return resolutions; + } + ts.loadWithModeAwareCache = loadWithModeAwareCache; /* @internal */ function forEachResolvedProjectReference(resolvedProjectReferences, cb) { return forEachProjectReference(/*projectReferences*/ undefined, resolvedProjectReferences, function (resolvedRef, parent) { return resolvedRef && cb(resolvedRef, parent); }); @@ -111492,9 +113520,8 @@ var ts; // Visit project references first if (cbRef) { var result = cbRef(projectReferences, parent); - if (result) { + if (result) return result; - } } return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) { if (resolvedRef && (seenResolvedRefs === null || seenResolvedRefs === void 0 ? void 0 : seenResolvedRefs.has(resolvedRef.sourceFile.path))) { @@ -111539,7 +113566,7 @@ var ts; switch (kind) { case ts.FileIncludeKind.Import: var importLiteral = getModuleNameStringLiteralAt(file, index); - packageId = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text)) === null || _e === void 0 ? void 0 : _e.packageId; + packageId = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text, getModeForResolutionAtIndex(file, index))) === null || _e === void 0 ? void 0 : _e.packageId; if (importLiteral.pos === -1) return { file: file, packageId: packageId, text: importLiteral.text }; pos = ts.skipTrivia(file.text, importLiteral.pos); @@ -111550,7 +113577,7 @@ var ts; break; case ts.FileIncludeKind.TypeReferenceDirective: (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); - packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName))) === null || _g === void 0 ? void 0 : _g.packageId; + packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), file.impliedNodeFormat)) === null || _g === void 0 ? void 0 : _g.packageId; break; case ts.FileIncludeKind.LibReferenceDirective: (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end); @@ -111637,6 +113664,33 @@ var ts; configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; + /** + * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the + * `options` parameter. + * + * @param fileName The normalized absolute path to check the format of (it need not exist on disk) + * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often + * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data + * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution` + * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format + */ + function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { + switch (ts.getEmitModuleResolutionKind(options)) { + case ts.ModuleResolutionKind.Node12: + case ts.ModuleResolutionKind.NodeNext: + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline + default: + return undefined; + } + function lookupFromPackageJson() { + var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options); + return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + } + } + ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; /** * Determine if source file needs to be re-created even if its text hasn't changed */ @@ -111657,7 +113711,7 @@ var ts; }; } function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { - var _a, _b, _c; + var _a, _b, _c, _d; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; @@ -111699,7 +113753,7 @@ var ts; var programDiagnostics = ts.createDiagnosticCollection(); var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); - var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); + var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); // Map storing if there is emit blocking diagnostics for given input var hasEmitBlockingDiagnostics = new ts.Map(); var _compilerOptionsObjectLiteralSyntax; @@ -111708,7 +113762,7 @@ var ts; var actualResolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) { + actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -111717,11 +113771,12 @@ var ts; withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName); return withExtension; }); }; + moduleResolutionCache = (_a = host.getModuleResolutionCache) === null || _a === void 0 ? void 0 : _a.call(host); } else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); - var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 - actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; + var loader_1 = function (moduleName, resolverMode, containingFileName, redirectedReference) { return ts.resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; }; // TODO: GH#18217 + actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, _reusedNames, redirectedReference) { return loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), containingFile, containingFileName, redirectedReference, loader_1); }; } var actualResolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { @@ -111757,9 +113812,9 @@ var ts; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; var mapFromToProjectReferenceRedirectSource; - var useSourceOfProjectReferenceRedirect = !!((_a = host.useSourceOfProjectReferenceRedirect) === null || _a === void 0 ? void 0 : _a.call(host)) && + var useSourceOfProjectReferenceRedirect = !!((_b = host.useSourceOfProjectReferenceRedirect) === null || _b === void 0 ? void 0 : _b.call(host)) && !options.disableSourceOfProjectReferenceRedirect; - var _d = updateHostForUseSourceOfProjectReferenceRedirect({ + var _e = updateHostForUseSourceOfProjectReferenceRedirect({ compilerHost: host, getSymlinkCache: getSymlinkCache, useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect, @@ -111767,7 +113822,8 @@ var ts; getResolvedProjectReferences: getResolvedProjectReferences, getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, forEachResolvedProjectReference: forEachResolvedProjectReference - }), onProgramCreateComplete = _d.onProgramCreateComplete, fileExists = _d.fileExists, directoryExists = _d.directoryExists; + }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; + var readFile = host.readFile.bind(host); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -111826,7 +113882,7 @@ var ts; var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { - processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_b = resolutions[i]) === null || _b === void 0 ? void 0 : _b.packageId }); + processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_c = resolutions[i]) === null || _c === void 0 ? void 0 : _c.packageId }); } ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -111843,7 +113899,7 @@ var ts; } else { ts.forEach(options.lib, function (libFileName, index) { - processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.LibFile, index: index }); + processRootFile(pathForLibFile(libFileName), /*isDefaultLib*/ true, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.LibFile, index: index }); }); } } @@ -111942,9 +113998,10 @@ var ts; isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, emitBuildInfo: emitBuildInfo, fileExists: fileExists, + readFile: readFile, directoryExists: directoryExists, getSymlinkCache: getSymlinkCache, - realpath: (_c = host.realpath) === null || _c === void 0 ? void 0 : _c.bind(host), + realpath: (_d = host.realpath) === null || _d === void 0 ? void 0 : _d.bind(host), useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getFileIncludeReasons: function () { return fileReasons; }, structureIsReused: structureIsReused, @@ -111974,7 +114031,7 @@ var ts; var redirectedReference = getRedirectReferenceForResolution(containingFile); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); - var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference); + var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -111995,11 +114052,11 @@ var ts; } function getRedirectReferenceForResolution(file) { var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName); - if (redirect || !ts.fileExtensionIs(file.originalFileName, ".d.ts" /* Dts */)) + if (redirect || !ts.fileExtensionIsOneOf(file.originalFileName, [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */])) return redirect; // The originalFileName could not be actual source file name if file found was d.ts from referecned project // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case - var resultFromDts = getRedirectReferenceForResolutionFromSourceOfProject(file.originalFileName, file.path); + var resultFromDts = getRedirectReferenceForResolutionFromSourceOfProject(file.path); if (resultFromDts) return resultFromDts; // If preserveSymlinks is true, module resolution wont jump the symlink @@ -112008,12 +114065,11 @@ var ts; // file is from node_modules to avoid having to run real path on all file paths if (!host.realpath || !options.preserveSymlinks || !ts.stringContains(file.originalFileName, ts.nodeModulesPathPart)) return undefined; - var realDeclarationFileName = host.realpath(file.originalFileName); - var realDeclarationPath = toPath(realDeclarationFileName); - return realDeclarationPath === file.path ? undefined : getRedirectReferenceForResolutionFromSourceOfProject(realDeclarationFileName, realDeclarationPath); + var realDeclarationPath = toPath(host.realpath(file.originalFileName)); + return realDeclarationPath === file.path ? undefined : getRedirectReferenceForResolutionFromSourceOfProject(realDeclarationPath); } - function getRedirectReferenceForResolutionFromSourceOfProject(fileName, filePath) { - var source = getSourceOfProjectReferenceRedirect(fileName); + function getRedirectReferenceForResolutionFromSourceOfProject(filePath) { + var source = getSourceOfProjectReferenceRedirect(filePath); if (ts.isString(source)) return getResolvedProjectReferenceToRedirect(source); if (!source) @@ -112041,8 +114097,8 @@ var ts; } return ts.libs.length + 2; } - function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) { - return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache); + function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, mode) { + return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode); } function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); @@ -112083,13 +114139,15 @@ 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_14 = []; + var result_13 = []; + var i = 0; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { var moduleName = moduleNames_1[_i]; - var resolvedModule = file.resolvedModules.get(moduleName); - result_14.push(resolvedModule); + var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i)); + i++; + result_13.push(resolvedModule); } - return result_14; + return result_13; } // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules @@ -112114,7 +114172,7 @@ var ts; var moduleName = moduleNames[i]; // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) { - var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName); + var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i)); if (oldResolvedModule) { if (ts.isTraceEnabled(options, host)) { ts.trace(host, oldResolvedModule.packageId ? @@ -112138,7 +114196,7 @@ var ts; } } else { - resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName); + resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, i); } if (resolvesToAmbientModuleInNonModifiedFile) { (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker; @@ -112175,8 +114233,10 @@ var ts; return result; // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. - function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) { - var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName); + function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, index) { + if (index >= ts.length(oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.imports) + ts.length(oldSourceFile === null || oldSourceFile === void 0 ? void 0 : oldSourceFile.moduleAugmentations)) + return false; // mode index out of bounds, don't reuse resolution + var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName, oldSourceFile && getModeForResolutionAtIndex(oldSourceFile, index)); var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile) { // In the old program, we resolved to an ambient module that was in the same @@ -112259,8 +114319,8 @@ var ts; for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { var oldSourceFile = oldSourceFiles_2[_i]; var newSourceFile = host.getSourceFileByPath - ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target, /*onError*/ undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, options.target, /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 + ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile) + : host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { return 0 /* Not */; } @@ -112367,10 +114427,10 @@ var ts; var moduleNames = getModuleNames(newSourceFile); var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile); // ensure that module resolution results are still correct - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { newSourceFile.resolvedModules = oldSourceFile.resolvedModules; @@ -112379,10 +114439,10 @@ var ts; var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); }); var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile); // ensure that types resolutions are still correct - var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (typeReferenceEesolutionsChanged) { + var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); + if (typeReferenceResolutionsChanged) { structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, typeReferenceResolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -112506,7 +114566,7 @@ var ts; return equalityComparer(file.fileName, getDefaultLibraryFileName()); } else { - return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); + return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, pathForLibFile(libFileName)); }); } } function getDiagnosticsProducingTypeChecker() { @@ -112725,22 +114785,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 162 /* Parameter */: - case 165 /* PropertyDeclaration */: - case 167 /* MethodDeclaration */: + case 163 /* Parameter */: + case 166 /* PropertyDeclaration */: + case 168 /* 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 166 /* MethodSignature */: - case 169 /* Constructor */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 211 /* FunctionExpression */: - case 254 /* FunctionDeclaration */: - case 212 /* ArrowFunction */: - case 252 /* VariableDeclaration */: + case 167 /* MethodSignature */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 212 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 213 /* ArrowFunction */: + case 253 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -112748,58 +114808,58 @@ var ts; } } switch (node.kind) { - case 265 /* ImportClause */: + case 266 /* 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 270 /* ExportDeclaration */: + case 271 /* 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 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 289 /* HeritageClause */: + case 290 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 117 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 256 /* InterfaceDeclaration */: + case 257 /* 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 259 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(141 /* NamespaceKeyword */) : ts.tokenToString(140 /* ModuleKeyword */); + case 260 /* ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 257 /* TypeAliasDeclaration */: + case 258 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 258 /* EnumDeclaration */: + case 259 /* 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 228 /* NonNullExpression */: + case 229 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 227 /* AsExpression */: + case 228 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 209 /* TypeAssertionExpression */: + case 210 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -112808,29 +114868,29 @@ 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 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 */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 168 /* MethodDeclaration */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 212 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 213 /* 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 235 /* VariableStatement */: + case 236 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 235 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 236 /* VariableStatement */); return "skip"; } break; - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -112842,19 +114902,19 @@ var ts; return "skip"; } break; - case 162 /* Parameter */: + case 163 /* 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 206 /* CallExpression */: - case 207 /* NewExpression */: - case 226 /* ExpressionWithTypeArguments */: - case 277 /* JsxSelfClosingElement */: - case 278 /* JsxOpeningElement */: - case 208 /* TaggedTemplateExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: + case 227 /* ExpressionWithTypeArguments */: + case 278 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: + case 209 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -112876,10 +114936,10 @@ var ts; case 123 /* PublicKeyword */: case 121 /* PrivateKeyword */: case 122 /* ProtectedKeyword */: - case 143 /* ReadonlyKeyword */: - case 134 /* DeclareKeyword */: + case 144 /* ReadonlyKeyword */: + case 135 /* DeclareKeyword */: case 126 /* AbstractKeyword */: - case 157 /* OverrideKeyword */: + case 158 /* 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. @@ -112934,9 +114994,8 @@ var ts; return ts.sortAndDeduplicateDiagnostics(ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile())); } function getOptionsDiagnosticsOfConfigFile() { - if (!options.configFile) { + if (!options.configFile) return ts.emptyArray; - } var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName); forEachResolvedProjectReference(function (resolvedRef) { diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName)); @@ -112962,7 +115021,7 @@ var ts; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); - var importDecl = ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference); + var importDecl = ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); @@ -113014,6 +115073,7 @@ var ts; // An ExternalImportDeclaration in an AmbientExternalModuleDeclaration may reference other external modules // 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))) { + ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here imports = ts.append(imports, moduleNameExpr); if (!usesUriStyleNodeCoreModules && currentNodeModulesDepth === 0 && !file.isDeclarationFile) { usesUriStyleNodeCoreModules = ts.startsWith(moduleNameExpr.text, "node:"); @@ -113022,6 +115082,7 @@ var ts; } else if (ts.isModuleDeclaration(node)) { if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. // This will happen in two cases: @@ -113057,13 +115118,16 @@ var ts; while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (isJavaScriptFile && ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { + ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here imports = ts.append(imports, node.arguments[0]); } - // we have to check the argument list has length of 1. We will still have to process these even though we have parsing error. - else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) { + // we have to check the argument list has length of at least 1. We will still have to process these even though we have parsing error. + else if (ts.isImportCall(node) && node.arguments.length >= 1 && ts.isStringLiteralLike(node.arguments[0])) { + ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here imports = ts.append(imports, node.arguments[0]); } else if (ts.isLiteralImportTypeNode(node)) { + ts.setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here imports = ts.append(imports, node.argument.literal); } } @@ -113089,7 +115153,7 @@ var ts; var libName = ts.toFileNameLowerCase(ref.fileName); var libFileName = ts.libMap.get(libName); if (libFileName) { - return getSourceFile(ts.combinePaths(defaultLibraryPath, libFileName)); + return getSourceFile(pathForLibFile(libFileName)); } } /** This should have similar behavior to 'processSourceFile' without diagnostics or mutation. */ @@ -113099,13 +115163,13 @@ var ts; function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, reason) { if (ts.hasExtension(fileName)) { var canonicalFileName_1 = host.getCanonicalFileName(fileName); - if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) { + if (!options.allowNonTsExtensions && !ts.forEach(ts.flatten(supportedExtensionsWithJsonIfResolveJsonModule), function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) { if (fail) { if (ts.hasJSFileExtension(canonicalFileName_1)) { fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName); } else { - fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'"); + fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + ts.flatten(supportedExtensions).join("', '") + "'"); } } return undefined; @@ -113135,15 +115199,16 @@ var ts; fail(ts.Diagnostics.File_0_not_found, fileName); return undefined; } - var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); }); + // Only try adding extensions from the first supported group (which should be .ts/.tsx/.d.ts) + var sourceFileWithAddedExtension = ts.forEach(supportedExtensions[0], function (extension) { return getSourceFile(fileName + extension); }); if (fail && !sourceFileWithAddedExtension) - fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'"); + fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + ts.flatten(supportedExtensions).join("', '") + "'"); return sourceFileWithAddedExtension; } } /** This has side effects through `findSourceFile`. */ function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, reason) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, reason, packageId); }, // TODO: GH#18217 + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -113185,19 +115250,20 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { + function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], }); - var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId); + var result = findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; } - function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { + function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { + var path = toPath(fileName); if (useSourceOfProjectReferenceRedirect) { - var source = getSourceOfProjectReferenceRedirect(fileName); + var source = getSourceOfProjectReferenceRedirect(path); // If preserveSymlinks is true, module resolution wont jump the symlink // but the resolved real path may be the .d.ts from project reference // Note:: Currently we try the real path only if the @@ -113207,13 +115273,13 @@ var ts; options.preserveSymlinks && ts.isDeclarationFileName(fileName) && ts.stringContains(fileName, ts.nodeModulesPathPart)) { - var realPath = host.realpath(fileName); - if (realPath !== fileName) + var realPath = toPath(host.realpath(fileName)); + if (realPath !== path) source = getSourceOfProjectReferenceRedirect(realPath); } if (source) { var file_1 = ts.isString(source) ? - findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, reason, packageId) : + findSourceFile(source, isDefaultLib, ignoreNoDefaultLib, reason, packageId) : undefined; if (file_1) addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); @@ -113281,7 +115347,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, ts.getEmitScriptTarget(options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -113309,6 +115375,10 @@ var ts; file.path = path; file.resolvedPath = toPath(fileName); file.originalFileName = originalFileName; + // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache + // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way + // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront. + file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); addFileIncludeReason(file, reason); if (host.useCaseSensitiveFileNames()) { var pathLowerCase = ts.toFileNameLowerCase(path); @@ -113393,8 +115463,8 @@ var ts; function forEachResolvedProjectReference(cb) { return ts.forEachResolvedProjectReference(resolvedProjectReferences, cb); } - function getSourceOfProjectReferenceRedirect(file) { - if (!ts.isDeclarationFileName(file)) + function getSourceOfProjectReferenceRedirect(path) { + if (!ts.isDeclarationFileName(path)) return undefined; if (mapFromToProjectReferenceRedirectSource === undefined) { mapFromToProjectReferenceRedirectSource = new ts.Map(); @@ -113416,7 +115486,7 @@ var ts; } }); } - return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + return mapFromToProjectReferenceRedirectSource.get(path); } function isSourceOfProjectReferenceRedirect(fileName) { return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); @@ -113499,13 +115569,31 @@ var ts; resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); } } + function pathForLibFile(libFileName) { + // Support resolving to lib.dom.d.ts -> @typescript/lib-dom, and + // lib.dom.iterable.d.ts -> @typescript/lib-dom/iterable + // lib.es2015.symbol.wellknown.d.ts -> @typescript/lib-es2015/symbol-wellknown + var components = libFileName.split("."); + var path = components[1]; + var i = 2; + while (components[i] && components[i] !== "d") { + path += (i === 2 ? "/" : "-") + components[i]; + i++; + } + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); + if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { + return localOverrideModuleResult.resolvedModule.resolvedFileName; + } + return ts.combinePaths(defaultLibraryPath, libFileName); + } function processLibReferenceDirectives(file) { ts.forEach(file.libReferenceDirectives, function (libReference, index) { var libName = ts.toFileNameLowerCase(libReference.fileName); var libFileName = ts.libMap.get(libName); if (libFileName) { // we ignore any 'no-default-lib' reference set on this file. - processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true, /*ignoreNoDefaultLib*/ true, { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }); + processRootFile(pathForLibFile(libFileName), /*isDefaultLib*/ true, /*ignoreNoDefaultLib*/ true, { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }); } else { var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); @@ -113534,7 +115622,7 @@ var ts; var optionsForFile = (useSourceOfProjectReferenceRedirect ? (_a = getRedirectReferenceForResolution(file)) === null || _a === void 0 ? void 0 : _a.commandLine.options : undefined) || options; for (var index = 0; index < moduleNames.length; index++) { var resolution = resolutions[index]; - ts.setResolvedModule(file, moduleNames[index], resolution); + ts.setResolvedModule(file, moduleNames[index], resolution, getModeForResolutionAtIndex(file, index)); if (!resolution) { continue; } @@ -113564,8 +115652,7 @@ var ts; modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { - var path = toPath(resolvedFileName); - findSourceFile(resolvedFileName, path, + findSourceFile(resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.packageId); } @@ -113641,6 +115728,21 @@ var ts; return resolvedRef; } function verifyCompilerOptions() { + var isNightly = ts.stringContains(ts.version, "-dev"); + if (!isNightly) { + if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) { + createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12"); + } + else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) { + createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "nodenext"); + } + else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) { + createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "node12"); + } + else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { + createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "nodenext"); + } + } if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } @@ -113758,7 +115860,7 @@ var ts; if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict"); } - var languageVersion = options.target || 0 /* ES3 */; + var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { @@ -113789,7 +115891,9 @@ var ts; } } if (options.resolveJsonModule) { - if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) { + if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && + ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 && + ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) { createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } // Any emit other than common js, amd, es2015 or esnext is error @@ -113863,6 +115967,9 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } + if (options.preserveValueImports && ts.getEmitModuleKind(options) < ts.ModuleKind.ES2015) { + createOptionValueDiagnostic("importsNotUsedAsValues", ts.Diagnostics.Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later); + } // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files if (!options.noEmit && !options.suppressOutputPathCheck) { var emitHost = getEmitHost(); @@ -114016,7 +116123,7 @@ var ts; message = ts.Diagnostics.File_is_library_specified_here; break; } - var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options.target ? key : undefined; }); + var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === ts.getEmitScriptTarget(options) ? key : undefined; }); configFileNode = target ? getOptionsSyntaxByValue("target", target) : undefined; message = ts.Diagnostics.File_is_default_library_for_target_specified_here; break; @@ -114114,8 +116221,8 @@ var ts; function createDiagnosticForOptionName(message, option1, option2, option3) { createDiagnosticForOption(/*onKey*/ true, option1, option2, message, option1, option2, option3); } - function createOptionValueDiagnostic(option1, message, arg0) { - createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0); + function createOptionValueDiagnostic(option1, message, arg0, arg1) { + createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0, arg1); } function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) { var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; }); @@ -114184,7 +116291,7 @@ var ts; if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } - if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensions) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) { + if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || @@ -114287,7 +116394,7 @@ var ts; return fileOrDirectoryExistsUsingSource(file, /*isFile*/ true); } function fileExistsIfProjectReferenceDts(file) { - var source = host.getSourceOfProjectReferenceRedirect(file); + var source = host.getSourceOfProjectReferenceRedirect(host.toPath(file)); return source !== undefined ? ts.isString(source) ? originalFileExists.call(host.compilerHost, source) : true : undefined; @@ -114645,13 +116752,11 @@ var ts; var checker = program.getTypeChecker(); for (var _d = 0, _e = sourceFile.moduleAugmentations; _d < _e.length; _d++) { var moduleName = _e[_d]; - if (!ts.isStringLiteral(moduleName)) { + if (!ts.isStringLiteral(moduleName)) continue; - } var symbol = checker.getSymbolAtLocation(moduleName); - if (!symbol) { + if (!symbol) continue; - } // Add any file other than our own as reference addReferenceFromAmbientModule(symbol); } @@ -114718,7 +116823,7 @@ var ts; } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined }); + fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat }); } return { fileInfos: fileInfos, @@ -114812,7 +116917,7 @@ var ts; /*forceDtsEmit*/ true); var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); if (firstDts_1) { - ts.Debug.assert(ts.fileExtensionIs(firstDts_1.name, ".d.ts" /* Dts */), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); + ts.Debug.assert(ts.fileExtensionIsOneOf(firstDts_1.name, [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */]), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); @@ -115110,12 +117215,10 @@ var ts; } else if (canCopySemanticDiagnostics) { var sourceFile = newProgram.getSourceFileByPath(sourceFilePath); - if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) { + if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) return; - } - if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) { + if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) return; - } // Unchanged file copy diagnostics var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath); if (diagnostics) { @@ -115138,6 +117241,14 @@ var ts; ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } + if (useOldState) { + // Any time the interpretation of a source file changes, mark it as changed + ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { + if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath).impliedFormat !== info.impliedFormat) { + state.changedFilesSet.add(sourceFilePath); + } + }); + } state.buildInfoEmitPending = !!state.changedFilesSet.size; return state; } @@ -115534,13 +117645,13 @@ var ts; var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; return value.version === actualSignature ? value.affectsGlobalScope ? - { version: value.version, signature: undefined, affectsGlobalScope: true } : + { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } : value.version : actualSignature !== undefined ? signature === undefined ? value : - { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } : - { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope }; + { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat }; }); var referencedMap; if (state.referencedMap) { @@ -115960,10 +118071,10 @@ var ts; } function toBuilderStateFileInfo(fileInfo) { return ts.isString(fileInfo) ? - { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } : + { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined, impliedFormat: undefined } : ts.isString(fileInfo.signature) ? fileInfo : - { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope }; + { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat }; } ts.toBuilderStateFileInfo = toBuilderStateFileInfo; function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) { @@ -116301,14 +118412,14 @@ var ts; } function resolveNamesWithLocalCache(_a) { 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 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, containingSourceFile = _a.containingSourceFile; var path = resolutionHost.toPath(containingFile); - var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path); + var resolutionsInFile = cache.get(path) || cache.set(path, ts.createModeAwareCache()).get(path); var dirPath = ts.getDirectoryPath(path); var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); var perDirectoryResolution = perDirectoryCache.get(dirPath); if (!perDirectoryResolution) { - perDirectoryResolution = new ts.Map(); + perDirectoryResolution = ts.createModeAwareCache(); perDirectoryCache.set(dirPath, perDirectoryResolution); } var resolvedModules = []; @@ -116320,17 +118431,20 @@ var ts; var unmatchedRedirects = oldRedirect ? !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path : !!redirectedReference; - var seenNamesInFile = new ts.Map(); - for (var _i = 0, names_3 = names; _i < names_3.length; _i++) { - var name = names_3[_i]; - var resolution = resolutionsInFile.get(name); + var seenNamesInFile = ts.createModeAwareCache(); + var i = 0; + for (var _i = 0, names_4 = names; _i < names_4.length; _i++) { + var name = names_4[_i]; + var mode = containingSourceFile ? ts.getModeForResolutionAtIndex(containingSourceFile, i) : undefined; + i++; + var resolution = resolutionsInFile.get(name, mode); // Resolution is valid if it is present and not invalidated - if (!seenNamesInFile.has(name) && + if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) { var existingResolution = resolution; - var resolutionInDirectory = perDirectoryResolution.get(name); + var resolutionInDirectory = perDirectoryResolution.get(name, mode); if (resolutionInDirectory) { resolution = resolutionInDirectory; var host = ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost; @@ -116350,10 +118464,13 @@ var ts; } } else { - resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference); - perDirectoryResolution.set(name, resolution); + resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile); + perDirectoryResolution.set(name, mode, resolution); + if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) { + resolutionHost.onDiscoveredSymlink(); + } } - resolutionsInFile.set(name, resolution); + resolutionsInFile.set(name, mode, resolution); watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName); if (existingResolution) { stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName); @@ -116366,7 +118483,7 @@ var ts; } else { var host = ((_d = resolutionHost.getCompilerHost) === null || _d === void 0 ? void 0 : _d.call(resolutionHost)) || resolutionHost; - if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name)) { + if (ts.isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) { var resolved = getResolutionWithResolvedFileName(resolution); ts.trace(host, loader === resolveModuleName ? (resolved === null || resolved === void 0 ? void 0 : resolved.resolvedFileName) ? @@ -116382,14 +118499,14 @@ var ts; } } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); - seenNamesInFile.set(name, true); + seenNamesInFile.set(name, mode, true); resolvedModules.push(getResolutionWithResolvedFileName(resolution)); } // Stop watching and remove the unused name - resolutionsInFile.forEach(function (resolution, name) { - if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) { + resolutionsInFile.forEach(function (resolution, name, mode) { + if (!seenNamesInFile.has(name, mode) && !ts.contains(reusedNames, name)) { stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName); - resolutionsInFile.delete(name); + resolutionsInFile.delete(name, mode); } }); return resolvedModules; @@ -116423,7 +118540,7 @@ var ts; shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, }); } - function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) { + function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile) { return resolveNamesWithLocalCache({ names: moduleNames, containingFile: containingFile, @@ -116435,11 +118552,14 @@ var ts; shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); }, reusedNames: reusedNames, logChanges: logChangesWhenResolvingModule, + containingSourceFile: containingSourceFile, }); } - function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) { + function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode) { var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile)); - return cache && cache.get(moduleName); + if (!cache) + return undefined; + return cache.get(moduleName, resolutionMode); } function isNodeModulesAtTypesDirectory(dirPath) { return ts.endsWith(dirPath, "/node_modules/@types"); @@ -116638,18 +118758,15 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) { + if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) return; - } var program = resolutionHost.getCurrentProgram(); - if (!program) { + if (!program) return; - } // If this file is input file for the referenced project, get it var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath); - if (!resolvedProjectReference) { + if (!resolvedProjectReference) return; - } // filePath is for the projectReference and the containing file is from this project reference, invalidate the resolution resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); }); } @@ -116820,6 +118937,11 @@ var ts; } } ts.createResolutionCache = createResolutionCache; + function resolutionIsSymlink(resolution) { + var _a, _b; + return !!(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.originalPath) || + ((_b = resolution.resolvedTypeReferenceDirective) === null || _b === void 0 ? void 0 : _b.originalPath)); + } })(ts || (ts = {})); // Used by importFixes, getEditsForFileRename, and declaration emit to synthesize import module specifiers. /* @internal */ @@ -116841,7 +118963,7 @@ var ts; Ending[Ending["Index"] = 1] = "Index"; Ending[Ending["JsExtension"] = 2] = "JsExtension"; })(Ending || (Ending = {})); - function getPreferences(_a, compilerOptions, importingSourceFile) { + function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : @@ -116855,21 +118977,39 @@ var ts; case "minimal": return 0 /* Minimal */; case "index": return 1 /* Index */; case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) ? 2 /* JsExtension */ + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; } } } - function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { + function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSFileExtension(oldImportSpecifier) ? + ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? 2 /* JsExtension */ : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } + function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { + if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12 + && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) { + return false; + } + return ts.getImpliedNodeFormatForFile(importingSourceFileName, /*packageJsonInfoCache*/ undefined, getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS; + } + function getModuleResolutionHost(host) { + var _a; + return { + fileExists: host.fileExists, + readFile: ts.Debug.checkDefined(host.readFile), + directoryExists: host.directoryExists, + getCurrentDirectory: host.getCurrentDirectory, + realpath: host.realpath, + useCaseSensitiveFileNames: (_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host), + }; + } 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, importingSourceFileName, host), {}); if (res === oldImportSpecifier) return undefined; return res; @@ -116877,7 +119017,7 @@ var ts; moduleSpecifiers_1.updateModuleSpecifier = updateModuleSpecifier; // Note: importingSourceFile is just for usesJsExtensionOnImports function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host) { - return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences({}, compilerOptions, importingSourceFile), {}); + return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {}); } moduleSpecifiers_1.getModuleSpecifier = getModuleSpecifier; function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, preferences) { @@ -116931,7 +119071,7 @@ var ts; moduleSpecifiers_1.getModuleSpecifiersWithCacheInfo = getModuleSpecifiersWithCacheInfo; function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences) { var info = getInfo(importingSourceFile.path, host); - var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); + var preferences = getPreferences(host, 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) return undefined; @@ -117094,9 +119234,9 @@ var ts; 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_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); - if (result_15) - return result_15; + var result_14 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); + if (result_14) + return result_14; } var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath(); var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd); @@ -117116,10 +119256,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_16 = cb(option, target === referenceRedirect); + var result_15 = cb(option, target === referenceRedirect); shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths - if (result_16) - return result_16; + if (result_15) + return result_15; } }); }); @@ -117265,6 +119405,78 @@ var ts; } } } + var MatchingMode; + (function (MatchingMode) { + MatchingMode[MatchingMode["Exact"] = 0] = "Exact"; + MatchingMode[MatchingMode["Directory"] = 1] = "Directory"; + MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; + })(MatchingMode || (MatchingMode = {})); + function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { + if (mode === void 0) { mode = 0 /* Exact */; } + if (typeof exports === "string") { + var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); + var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; + switch (mode) { + case 0 /* Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + return { moduleFileToTry: packageName }; + } + break; + case 1 /* Directory */: + if (ts.containsPath(pathOrPattern, targetFilePath)) { + var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); + return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; + } + break; + case 2 /* Pattern */: + var starPos = pathOrPattern.indexOf("*"); + var leadingSlice = pathOrPattern.slice(0, starPos); + var trailingSlice = pathOrPattern.slice(starPos + 1); + if (ts.startsWith(targetFilePath, leadingSlice) && ts.endsWith(targetFilePath, trailingSlice)) { + var starReplacement = targetFilePath.slice(leadingSlice.length, targetFilePath.length - trailingSlice.length); + return { moduleFileToTry: packageName.replace("*", starReplacement) }; + } + if (extensionSwappedTarget && ts.startsWith(extensionSwappedTarget, leadingSlice) && ts.endsWith(extensionSwappedTarget, trailingSlice)) { + var starReplacement = extensionSwappedTarget.slice(leadingSlice.length, extensionSwappedTarget.length - trailingSlice.length); + return { moduleFileToTry: packageName.replace("*", starReplacement) }; + } + break; + } + } + else if (Array.isArray(exports)) { + return ts.forEach(exports, function (e) { return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, e, conditions); }); + } + else if (typeof exports === "object" && exports !== null) { // eslint-disable-line no-null/no-null + if (ts.allKeysStartWithDot(exports)) { + // sub-mappings + // 3 cases: + // * directory mappings (legacyish, key ends with / (technically allows index/extension resolution under cjs mode)) + // * pattern mappings (contains a *) + // * exact mappings (no *, does not end with /) + return ts.forEach(ts.getOwnKeys(exports), function (k) { + var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); + var mode = ts.endsWith(k, "/") ? 1 /* Directory */ + : ts.stringContains(k, "*") ? 2 /* Pattern */ + : 0 /* Exact */; + return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); + }); + } + else { + // conditional mapping + for (var _i = 0, _a = ts.getOwnKeys(exports); _i < _a.length; _i++) { + var key = _a[_i]; + if (key === "default" || conditions.indexOf(key) >= 0 || ts.isApplicableVersionedTypesKey(conditions, key)) { + var subTarget = exports[key]; + var result = tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, subTarget, conditions); + if (result) { + return result; + } + } + } + } + } + return undefined; + } function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) { var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPath === undefined) { @@ -117294,7 +119506,15 @@ var ts; var moduleFileNameForExtensionless = void 0; while (true) { // If the module could be imported by a directory name, use that directory's name - var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath; + var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports; + if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Classic) { + if (blockedByExports) { + return undefined; // File is under this package.json, but is not publicly exported - there's no way to name it via `node_modules` resolution + } + if (verbatimFromExports) { + return moduleFileToTry; + } + } if (packageRootPath) { moduleSpecifier = packageRootPath; isPackageRootPath = true; @@ -117324,13 +119544,24 @@ var ts; var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1); var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName); // For classic resolution, only allow importing from node_modules/@types, not other node_modules - return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName; + return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName; function tryDirectoryWithPackageJson(packageRootIndex) { var packageRootPath = path.substring(0, packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); var moduleFileToTry = path; if (host.fileExists(packageJsonPath)) { var packageJsonContent = JSON.parse(host.readFile(packageJsonPath)); + // TODO: Inject `require` or `import` condition based on the intended import mode + if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { + var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, packageJsonContent.name, packageJsonContent.exports, ["node", "types"]) : undefined; + if (fromExports) { + var withJsExtension = !ts.hasTSFileExtension(fromExports.moduleFileToTry) ? fromExports : { moduleFileToTry: ts.removeFileExtension(fromExports.moduleFileToTry) + tryGetJSExtensionForFile(fromExports.moduleFileToTry, options) }; + return __assign(__assign({}, withJsExtension), { verbatimFromExports: true }); + } + if (packageJsonContent.exports) { + return { moduleFileToTry: path, blockedByExports: true }; + } + } var versionPaths = packageJsonContent.typesVersions ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) : undefined; @@ -117367,7 +119598,7 @@ var ts; if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }]); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -117435,9 +119666,11 @@ var ts; }); } function removeExtensionAndIndexPostFix(fileName, ending, options) { - if (ts.fileExtensionIs(fileName, ".json" /* Json */)) + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { case 0 /* Minimal */: return ts.removeSuffix(noExtension, "/index"); @@ -117465,6 +119698,14 @@ var ts; case ".jsx" /* Jsx */: case ".json" /* Json */: return ext; + case ".d.mts" /* Dmts */: + case ".mts" /* Mts */: + case ".mjs" /* Mjs */: + return ".mjs" /* Mjs */; + case ".d.cts" /* Dcts */: + case ".cts" /* Cts */: + case ".cjs" /* Cjs */: + return ".cjs" /* Cjs */; default: return undefined; } @@ -117739,7 +119980,7 @@ var ts; case ts.FileIncludeKind.LibFile: if (reason.index !== undefined) return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Library_0_specified_in_compilerOptions, options.lib[reason.index]); - var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options.target ? key : undefined; }); + var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === ts.getEmitScriptTarget(options) ? key : undefined; }); return ts.chainDiagnosticMessages( /*details*/ undefined, target ? ts.Diagnostics.Default_library_for_target_0 : @@ -118162,7 +120403,7 @@ var ts; } return host.resolveModuleNames.apply(host, args); }) : - (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); }); + (function (moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile); }); compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? (function () { var args = []; @@ -118361,6 +120602,9 @@ var ts; sourceFilesCache.set(path, false); } } + if (sourceFile) { + sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings()); + } return sourceFile; } return hostSourceFile.sourceFile; @@ -118890,10 +121134,11 @@ var ts; var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined; if (!compilerHost.resolveModuleNames) { - var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; }; - compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) { - return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3); + var loader_3 = function (moduleName, resolverMode, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; }; + compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile) { + return ts.loadWithModeAwareCache(ts.Debug.checkEachDefined(moduleNames), ts.Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, loader_3); }; + compilerHost.getModuleResolutionCache = function () { return moduleResolutionCache; }; } if (!compilerHost.resolveTypeReferenceDirectives) { var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; @@ -119148,9 +121393,8 @@ var ts; if (!state.allProjectBuildPending) return; state.allProjectBuildPending = false; - if (state.options.watch) { + if (state.options.watch) reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); - } enableCache(state); var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { @@ -119317,11 +121561,11 @@ 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.lastCachedPackageJsonLookups.set(projectPath, state.moduleResolutionCache && ts.map(state.moduleResolutionCache.getPackageJsonInfoCache().entries(), function (_a) { + var path = _a[0], data = _a[1]; + return [state.host.realpath && data ? toPath(state, state.host.realpath(path)) : path, data]; + })); state.builderPrograms.set(projectPath, program); } step++; @@ -119666,7 +121910,6 @@ var ts; } if (!force) { var inputTime = ts.getModifiedTime(host, inputFile); - host.getModifiedTime(inputFile); if (inputTime > newestInputFileTime) { newestInputFileName = inputFile; newestInputFileTime = inputTime; @@ -120972,6 +123215,12 @@ var ts; ScriptElementKindModifier["jsModifier"] = ".js"; ScriptElementKindModifier["jsxModifier"] = ".jsx"; ScriptElementKindModifier["jsonModifier"] = ".json"; + ScriptElementKindModifier["dmtsModifier"] = ".d.mts"; + ScriptElementKindModifier["mtsModifier"] = ".mts"; + ScriptElementKindModifier["mjsModifier"] = ".mjs"; + ScriptElementKindModifier["dctsModifier"] = ".d.cts"; + ScriptElementKindModifier["ctsModifier"] = ".cts"; + ScriptElementKindModifier["cjsModifier"] = ".cjs"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); var ClassificationTypeNames; (function (ClassificationTypeNames) { @@ -121045,37 +123294,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - 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 */: + case 163 /* Parameter */: + case 202 /* BindingElement */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 294 /* PropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 291 /* CatchClause */: + case 284 /* JsxAttribute */: return 1 /* Value */; - case 161 /* TypeParameter */: - case 256 /* InterfaceDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 180 /* TypeLiteral */: + case 162 /* TypeParameter */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 181 /* TypeLiteral */: return 2 /* Type */; - case 340 /* JSDocTypedefTag */: + case 343 /* 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 294 /* EnumMember */: - case 255 /* ClassDeclaration */: + case 297 /* EnumMember */: + case 256 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -121085,16 +123334,16 @@ var ts; else { return 4 /* Namespace */; } - case 258 /* EnumDeclaration */: - case 267 /* NamedImports */: - case 268 /* ImportSpecifier */: - case 263 /* ImportEqualsDeclaration */: - case 264 /* ImportDeclaration */: - case 269 /* ExportAssignment */: - case 270 /* ExportDeclaration */: + case 259 /* EnumDeclaration */: + case 268 /* NamedImports */: + case 269 /* ImportSpecifier */: + case 264 /* ImportEqualsDeclaration */: + case 265 /* ImportDeclaration */: + case 270 /* ExportAssignment */: + case 271 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 300 /* SourceFile */: + case 303 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; @@ -121103,7 +123352,7 @@ var ts; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); var parent = node.parent; - if (node.kind === 300 /* SourceFile */) { + if (node.kind === 303 /* SourceFile */) { return 1 /* Value */; } else if (ts.isExportAssignment(parent) @@ -121153,11 +123402,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // 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 */; + var name = node.kind === 160 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 264 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 159 /* QualifiedName */) { + while (node.parent.kind === 160 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -121169,27 +123418,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 159 /* QualifiedName */) { - while (root.parent && root.parent.kind === 159 /* QualifiedName */) { + if (root.parent.kind === 160 /* QualifiedName */) { + while (root.parent && root.parent.kind === 160 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 176 /* TypeReference */ && !isLastClause; + return root.parent.kind === 177 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 204 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 204 /* PropertyAccessExpression */) { + if (root.parent.kind === 205 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 205 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 226 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 289 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 227 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 290 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 255 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || - (decl.kind === 256 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); + return (decl.kind === 256 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || + (decl.kind === 257 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); } return false; } @@ -121200,15 +123449,15 @@ var ts; switch (node.kind) { case 108 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 190 /* ThisType */: + case 191 /* ThisType */: return true; } switch (node.parent.kind) { - case 176 /* TypeReference */: + case 177 /* TypeReference */: return true; - case 198 /* ImportType */: + case 199 /* ImportType */: return !node.parent.isTypeOf; - case 226 /* ExpressionWithTypeArguments */: + case 227 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -121275,7 +123524,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 248 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 249 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -121336,22 +123585,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - 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 */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 294 /* PropertyAssignment */: + case 297 /* EnumMember */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 260 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 160 /* ComputedPropertyName */: + case 161 /* ComputedPropertyName */: return true; - case 194 /* LiteralType */: - return node.parent.parent.kind === 192 /* IndexedAccessType */; + case 195 /* LiteralType */: + return node.parent.parent.kind === 193 /* IndexedAccessType */; default: return false; } @@ -121375,17 +123624,17 @@ var ts; return undefined; } switch (node.kind) { - 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 */: + case 303 /* SourceFile */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 259 /* EnumDeclaration */: + case 260 /* ModuleDeclaration */: return node; } } @@ -121393,56 +123642,56 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 300 /* SourceFile */: + case 303 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: return "class" /* classElement */; - case 256 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 257 /* TypeAliasDeclaration */: - case 333 /* JSDocCallbackTag */: - case 340 /* JSDocTypedefTag */: + case 257 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 258 /* TypeAliasDeclaration */: + case 336 /* JSDocCallbackTag */: + case 343 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 258 /* EnumDeclaration */: return "enum" /* enumElement */; - case 252 /* VariableDeclaration */: + case 259 /* EnumDeclaration */: return "enum" /* enumElement */; + case 253 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 201 /* BindingElement */: + case 202 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 212 /* ArrowFunction */: - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: return "function" /* functionElement */; - case 170 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 171 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 171 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 172 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: var initializer = node.initializer; return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: - case 292 /* ShorthandPropertyAssignment */: - case 293 /* SpreadAssignment */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 295 /* ShorthandPropertyAssignment */: + case 296 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 174 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 173 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 172 /* CallSignature */: return "call" /* callSignatureElement */; - case 169 /* Constructor */: - case 168 /* ClassStaticBlockDeclaration */: + case 175 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 174 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 173 /* CallSignature */: return "call" /* callSignatureElement */; + case 170 /* Constructor */: + case 169 /* 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 */: + case 162 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 297 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 163 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 264 /* ImportEqualsDeclaration */: + case 269 /* ImportSpecifier */: + case 274 /* ExportSpecifier */: + case 267 /* NamespaceImport */: + case 273 /* NamespaceExport */: return "alias" /* alias */; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -121471,7 +123720,7 @@ var ts; } case 79 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 269 /* ExportAssignment */: + case 270 /* 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; @@ -121494,7 +123743,7 @@ var ts; return true; case 79 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 162 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 163 /* Parameter */; default: return false; } @@ -121559,42 +123808,42 @@ var ts; return false; } switch (n.kind) { - 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 */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 259 /* EnumDeclaration */: + case 204 /* ObjectLiteralExpression */: + case 200 /* ObjectBindingPattern */: + case 181 /* TypeLiteral */: + case 234 /* Block */: + case 261 /* ModuleBlock */: + case 262 /* CaseBlock */: + case 268 /* NamedImports */: + case 272 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 290 /* CatchClause */: + case 291 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 207 /* NewExpression */: + case 208 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 206 /* CallExpression */: - case 210 /* ParenthesizedExpression */: - case 189 /* ParenthesizedType */: + case 207 /* CallExpression */: + case 211 /* ParenthesizedExpression */: + case 190 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 177 /* FunctionType */: - case 178 /* ConstructorType */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - 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 */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 174 /* ConstructSignature */: + case 173 /* CallSignature */: + case 213 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -121604,65 +123853,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 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 237 /* IfStatement */: + case 238 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 202 /* ArrayLiteralExpression */: - case 200 /* ArrayBindingPattern */: - case 205 /* ElementAccessExpression */: - case 160 /* ComputedPropertyName */: - case 182 /* TupleType */: + case 203 /* ArrayLiteralExpression */: + case 201 /* ArrayBindingPattern */: + case 206 /* ElementAccessExpression */: + case 161 /* ComputedPropertyName */: + case 183 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 174 /* IndexSignature */: + case 175 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 287 /* CaseClause */: - case 288 /* DefaultClause */: + case 288 /* CaseClause */: + case 289 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 240 /* ForStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: - case 239 /* WhileStatement */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 240 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 238 /* DoStatement */: + case 239 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 179 /* TypeQuery */: + case 180 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 214 /* TypeOfExpression */: - case 213 /* DeleteExpression */: - case 215 /* VoidExpression */: - case 222 /* YieldExpression */: - case 223 /* SpreadElement */: + case 215 /* TypeOfExpression */: + case 214 /* DeleteExpression */: + case 216 /* VoidExpression */: + case 223 /* YieldExpression */: + case 224 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 221 /* TemplateExpression */: + case 222 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 231 /* TemplateSpan */: + case 232 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 270 /* ExportDeclaration */: - case 264 /* ImportDeclaration */: + case 271 /* ExportDeclaration */: + case 265 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 220 /* ConditionalExpression */: + case 221 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -121776,27 +124025,22 @@ var ts; }); return lastTypeNode; } - function getContextualTypeOrAncestorTypeNodeType(node, checker) { - var contextualType = checker.getContextualType(node); - if (contextualType) { + function getContextualTypeFromParentOrAncestorTypeNode(node, checker) { + var contextualType = getContextualTypeFromParent(node, checker); + 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); } - ts.getContextualTypeOrAncestorTypeNodeType = getContextualTypeOrAncestorTypeNodeType; + ts.getContextualTypeFromParentOrAncestorTypeNode = getContextualTypeFromParentOrAncestorTypeNode; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: return getAdjustedLocationForClass(node); - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -121891,11 +124135,11 @@ var ts; 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 === 151 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 142 /* NamespaceKeyword */ || node.kind === 141 /* 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)) { + node.kind === 136 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 148 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; @@ -121909,7 +124153,7 @@ var ts; return decl.name; } } - if (node.kind === 150 /* TypeKeyword */) { + if (node.kind === 151 /* TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -121976,12 +124220,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 144 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 145 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 154 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 155 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -122006,7 +124250,7 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 136 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 137 /* InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } @@ -122014,12 +124258,12 @@ var ts; return parent.name; } // /**/keyof [|T|] - if (node.kind === 139 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 139 /* KeyOfKeyword */ && + if (node.kind === 140 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 143 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 143 /* ReadonlyKeyword */ && + if (node.kind === 144 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 144 /* ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -122037,7 +124281,7 @@ var ts; 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 === 132 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { @@ -122056,7 +124300,7 @@ var ts; // for (... /**/in [|name|]) // for (... /**/of [|name|]) if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 158 /* OfKeyword */ && ts.isForOfStatement(parent)) { + node.kind === 159 /* OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -122101,28 +124345,85 @@ var ts; /** Get the token whose text contains the position */ function getTokenAtPositionWorker(sourceFile, position, allowPositionInLeadingTrivia, includePrecedingTokenAtEndPosition, includeEndPosition) { var current = sourceFile; - outer: while (true) { + var foundToken; + var _loop_1 = function () { // find the child that contains 'position' - for (var _i = 0, _a = current.getChildren(sourceFile); _i < _a.length; _i++) { - var child = _a[_i]; - var start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, /*includeJsDoc*/ true); + var children = current.getChildren(sourceFile); + var i = ts.binarySearchKey(children, position, function (_, i) { return i; }, function (middle, _) { + // This last callback is more of a selector than a comparator - + // `EqualTo` causes the `middle` result to be returned + // `GreaterThan` causes recursion on the left of the middle + // `LessThan` causes recursion on the right of the middle + // Let's say you have 3 nodes, spanning positons + // pos: 1, end: 3 + // pos: 3, end: 3 + // pos: 3, end: 5 + // and you're looking for the token at positon 3 - all 3 of these nodes are overlapping with position 3. + // In fact, there's a _good argument_ that node 2 shouldn't even be allowed to exist - depending on if + // the start or end of the ranges are considered inclusive, it's either wholly subsumed by the first or the last node. + // Unfortunately, such nodes do exist. :( - See fourslash/completionsImport_tsx.tsx - empty jsx attributes create + // a zero-length node. + // What also you may not expect is that which node we return depends on the includePrecedingTokenAtEndPosition flag. + // Specifically, if includePrecedingTokenAtEndPosition is set, we return the 1-3 node, while if it's unset, we + // return the 3-5 node. (The zero length node is never correct.) This is because the includePrecedingTokenAtEndPosition + // flag causes us to return the first node whose end position matches the position and which produces and acceptable token + // kind. Meanwhile, if includePrecedingTokenAtEndPosition is unset, we look for the first node whose start is <= the + // position and whose end is greater than the position. + var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { - // If this child begins after position, then all subsequent children will as well. - break; - } - var end = child.getEnd(); - if (position < end || (position === end && (child.kind === 1 /* EndOfFileToken */ || includeEndPosition))) { - current = child; - continue outer; + return 1 /* GreaterThan */; } - else if (includePrecedingTokenAtEndPosition && end === position) { - var previousToken = findPrecedingToken(position, sourceFile, child); - if (previousToken && includePrecedingTokenAtEndPosition(previousToken)) { - return previousToken; + // first element whose start position is before the input and whose end position is after or equal to the input + if (nodeContainsPosition(children[middle])) { + if (children[middle - 1]) { + // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position + if (nodeContainsPosition(children[middle - 1])) { + return 1 /* GreaterThan */; + } } + return 0 /* EqualTo */; } + // this complex condition makes us left-recur around a zero-length node when includePrecedingTokenAtEndPosition is set, rather than right-recur on it + if (includePrecedingTokenAtEndPosition && start === position && children[middle - 1] && children[middle - 1].getEnd() === position && nodeContainsPosition(children[middle - 1])) { + return 1 /* GreaterThan */; + } + return -1 /* LessThan */; + }); + if (foundToken) { + return { value: foundToken }; } - return current; + if (i >= 0 && children[i]) { + current = children[i]; + return "continue-outer"; + } + return { value: current }; + }; + outer: while (true) { + var state_1 = _loop_1(); + if (typeof state_1 === "object") + return state_1.value; + switch (state_1) { + case "continue-outer": continue outer; + } + } + function nodeContainsPosition(node) { + var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true); + if (start > position) { + // If this child begins after position, then all subsequent children will as well. + return false; + } + var end = node.getEnd(); + if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) { + return true; + } + else if (includePrecedingTokenAtEndPosition && end === position) { + var previousToken = findPrecedingToken(position, sourceFile, node); + if (previousToken && includePrecedingTokenAtEndPosition(previousToken)) { + foundToken = previousToken; + return true; + } + } + return false; } } /** @@ -122226,7 +124527,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 300 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 303 /* 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. @@ -122299,17 +124600,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 286 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 287 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 286 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 287 /* JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 279 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 280 /* JsxClosingElement */) { return true; } return false; @@ -122340,7 +124641,7 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 277 /* JsxSelfClosingElement */ && node.kind <= 286 /* JsxExpression */ + if (node.kind >= 278 /* JsxSelfClosingElement */ && node.kind <= 287 /* JsxExpression */ || node.kind === 11 /* JsxText */ || node.kind === 29 /* LessThanToken */ || node.kind === 31 /* GreaterThanToken */ @@ -122350,7 +124651,7 @@ var ts; || node.kind === 43 /* SlashToken */) { node = node.parent; } - else if (node.kind === 276 /* JsxElement */) { + else if (node.kind === 277 /* JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -122498,7 +124799,7 @@ var ts; // falls through case 112 /* TypeOfKeyword */: case 94 /* ExtendsKeyword */: - case 139 /* KeyOfKeyword */: + case 140 /* KeyOfKeyword */: case 24 /* DotToken */: case 51 /* BarToken */: case 57 /* QuestionToken */: @@ -122558,16 +124859,16 @@ var ts; result.push("deprecated" /* deprecatedModifier */); if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); - if (node.kind === 269 /* ExportAssignment */) + if (node.kind === 270 /* ExportAssignment */) result.push("export" /* exportedModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 176 /* TypeReference */ || node.kind === 206 /* CallExpression */) { + if (node.kind === 177 /* TypeReference */ || node.kind === 207 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 255 /* ClassDeclaration */ || node.kind === 256 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 256 /* ClassDeclaration */ || node.kind === 257 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -122612,18 +124913,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 202 /* ArrayLiteralExpression */ || - node.kind === 203 /* ObjectLiteralExpression */) { + if (node.kind === 203 /* ArrayLiteralExpression */ || + node.kind === 204 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 219 /* BinaryExpression */ && + if (node.parent.kind === 220 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 242 /* ForOfStatement */ && + if (node.parent.kind === 243 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -122631,7 +124932,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 291 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 294 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -122693,34 +124994,38 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 129 /* AnyKeyword */, + 130 /* AnyKeyword */, 128 /* AssertsKeyword */, - 156 /* BigIntKeyword */, - 132 /* BooleanKeyword */, + 157 /* BigIntKeyword */, + 133 /* BooleanKeyword */, 95 /* FalseKeyword */, - 136 /* InferKeyword */, - 139 /* KeyOfKeyword */, - 142 /* NeverKeyword */, + 137 /* InferKeyword */, + 140 /* KeyOfKeyword */, + 143 /* NeverKeyword */, 104 /* NullKeyword */, - 145 /* NumberKeyword */, - 146 /* ObjectKeyword */, - 143 /* ReadonlyKeyword */, - 148 /* StringKeyword */, - 149 /* SymbolKeyword */, + 146 /* NumberKeyword */, + 147 /* ObjectKeyword */, + 144 /* ReadonlyKeyword */, + 149 /* StringKeyword */, + 150 /* SymbolKeyword */, 110 /* TrueKeyword */, 114 /* VoidKeyword */, - 151 /* UndefinedKeyword */, - 152 /* UniqueKeyword */, - 153 /* UnknownKeyword */, + 152 /* UndefinedKeyword */, + 153 /* UniqueKeyword */, + 154 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 150 /* TypeKeyword */; + return node.kind === 151 /* TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; + function isTypeKeywordTokenOrIdentifier(node) { + return isTypeKeywordToken(node) || ts.isIdentifier(node) && node.text === "type"; + } + ts.isTypeKeywordTokenOrIdentifier = isTypeKeywordTokenOrIdentifier; /** True if the symbol is for an external module, as opposed to a namespace. */ function isExternalModuleSymbol(moduleSymbol) { return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; @@ -122751,7 +125056,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 160 /* ComputedPropertyName */ + return name.kind === 161 /* 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); @@ -122761,14 +125066,14 @@ var ts; return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!(s.externalModuleIndicator || s.commonJsModuleIndicator); }); } ts.programContainsModules = programContainsModules; - function programContainsEs6Modules(program) { + function programContainsEsModules(program) { return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator; }); } - ts.programContainsEs6Modules = programContainsEs6Modules; - function compilerOptionsIndicateEs6Modules(compilerOptions) { - return !!compilerOptions.module || compilerOptions.target >= 2 /* ES2015 */ || !!compilerOptions.noEmit; + ts.programContainsEsModules = programContainsEsModules; + function compilerOptionsIndicateEsModules(compilerOptions) { + return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit; } - ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules; + ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules; function createModuleSpecifierResolutionHost(program, host) { // Mix in `getSymlinkCache` from Program when host doesn't have it // in order for non-Project hosts to have a symlinks cache. @@ -122801,7 +125106,8 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, defaultImport || namedImports ? ts.factory.createImportClause(!!isTypeOnly, defaultImport, namedImports && namedImports.length ? ts.factory.createNamedImports(namedImports) : undefined) - : undefined, typeof moduleSpecifier === "string" ? makeStringLiteral(moduleSpecifier, quotePreference) : moduleSpecifier); + : undefined, typeof moduleSpecifier === "string" ? makeStringLiteral(moduleSpecifier, quotePreference) : moduleSpecifier, + /*assertClause*/ undefined); } ts.makeImport = makeImport; function makeStringLiteral(text, quotePreference) { @@ -122892,7 +125198,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 235 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 236 /* 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) { @@ -122970,7 +125276,10 @@ var ts; // Display-part writer helpers // #region function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 162 /* Parameter */; + var declaration = symbol.declarations ? ts.firstOrUndefined(symbol.declarations) : undefined; + return !!ts.findAncestor(declaration, function (n) { + return ts.isParameter(n) ? true : ts.isBindingElement(n) || ts.isObjectBindingPattern(n) || ts.isArrayBindingPattern(n) ? false : "quit"; + }); } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -123070,45 +125379,32 @@ var ts; if (flags & 3 /* Variable */) { return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } - else if (flags & 4 /* Property */) { + if (flags & 4 /* Property */) return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 32768 /* GetAccessor */) { + if (flags & 32768 /* GetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 65536 /* SetAccessor */) { + if (flags & 65536 /* SetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - } - else if (flags & 8 /* EnumMember */) { + if (flags & 8 /* EnumMember */) return ts.SymbolDisplayPartKind.enumMemberName; - } - else if (flags & 16 /* Function */) { + if (flags & 16 /* Function */) return ts.SymbolDisplayPartKind.functionName; - } - else if (flags & 32 /* Class */) { + if (flags & 32 /* Class */) return ts.SymbolDisplayPartKind.className; - } - else if (flags & 64 /* Interface */) { + if (flags & 64 /* Interface */) return ts.SymbolDisplayPartKind.interfaceName; - } - else if (flags & 384 /* Enum */) { + if (flags & 384 /* Enum */) return ts.SymbolDisplayPartKind.enumName; - } - else if (flags & 1536 /* Module */) { + if (flags & 1536 /* Module */) return ts.SymbolDisplayPartKind.moduleName; - } - else if (flags & 8192 /* Method */) { + if (flags & 8192 /* Method */) return ts.SymbolDisplayPartKind.methodName; - } - else if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeParameter */) return ts.SymbolDisplayPartKind.typeParameterName; - } - else if (flags & 524288 /* TypeAlias */) { + if (flags & 524288 /* TypeAlias */) return ts.SymbolDisplayPartKind.aliasName; - } - else if (flags & 2097152 /* Alias */) { + if (flags & 2097152 /* Alias */) return ts.SymbolDisplayPartKind.aliasName; - } return ts.SymbolDisplayPartKind.text; } } @@ -123164,9 +125460,9 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.linkText); } ts.linkTextPart = linkTextPart; - function linkNamePart(name, target) { + function linkNamePart(text, target) { return { - text: ts.getTextOfNode(name), + text: text, kind: ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.linkName], target: { fileName: ts.getSourceFileOfNode(target).fileName, @@ -123186,27 +125482,46 @@ var ts; : "linkplain"; var parts = [linkPart("{@" + prefix + " ")]; if (!link.name) { - if (link.text) { + if (link.text) parts.push(linkTextPart(link.text)); - } } else { var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name); + var suffix = findLinkNameEnd(link.text); + var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix); + var text = link.text.slice(suffix); var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]); if (decl) { - parts.push(linkNamePart(link.name, decl)); - if (link.text) { - parts.push(linkTextPart(link.text)); - } + parts.push(linkNamePart(name, decl)); + if (text) + parts.push(linkTextPart(text)); } else { - parts.push(linkTextPart(ts.getTextOfNode(link.name) + " " + link.text)); + parts.push(linkTextPart(name + (suffix ? "" : " ") + text)); } } parts.push(linkPart("}")); return parts; } ts.buildLinkParts = buildLinkParts; + function findLinkNameEnd(text) { + if (text.indexOf("()") === 0) + return 2; + if (text[0] !== "<") + return 0; + var brackets = 0; + var i = 0; + while (i < text.length) { + if (text[i] === "<") + brackets++; + if (text[i] === ">") + brackets--; + i++; + if (!brackets) + return i; + } + return 0; + } var carriageReturnLineFeed = "\r\n"; /** * The default is CRLF. @@ -123504,15 +125819,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 207 /* NewExpression */: + case 208 /* NewExpression */: return checker.getContextualType(parent); - case 219 /* BinaryExpression */: { + case 220 /* 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 287 /* CaseClause */: + case 288 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -123542,8 +125857,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 221 /* TemplateExpression */: - case 208 /* TaggedTemplateExpression */: + case 222 /* TemplateExpression */: + case 209 /* TaggedTemplateExpression */: return true; default: return false; @@ -123562,7 +125877,7 @@ var ts; function getTypeNodeIfAccessible(type, enclosingScope, program, host) { var checker = program.getTypeChecker(); var typeIsAccessible = true; - var notAccessible = function () { typeIsAccessible = false; }; + var notAccessible = function () { return typeIsAccessible = false; }; 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 */; @@ -123577,41 +125892,41 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 172 /* CallSignature */ - || kind === 173 /* ConstructSignature */ - || kind === 174 /* IndexSignature */ - || kind === 164 /* PropertySignature */ - || kind === 166 /* MethodSignature */; + return kind === 173 /* CallSignature */ + || kind === 174 /* ConstructSignature */ + || kind === 175 /* IndexSignature */ + || kind === 165 /* PropertySignature */ + || kind === 167 /* MethodSignature */; } ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 254 /* FunctionDeclaration */ - || kind === 169 /* Constructor */ - || kind === 167 /* MethodDeclaration */ - || kind === 170 /* GetAccessor */ - || kind === 171 /* SetAccessor */; + return kind === 255 /* FunctionDeclaration */ + || kind === 170 /* Constructor */ + || kind === 168 /* MethodDeclaration */ + || kind === 171 /* GetAccessor */ + || kind === 172 /* SetAccessor */; } ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 259 /* ModuleDeclaration */; + return kind === 260 /* ModuleDeclaration */; } ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; function syntaxRequiresTrailingSemicolonOrASI(kind) { - 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 */; + return kind === 236 /* VariableStatement */ + || kind === 237 /* ExpressionStatement */ + || kind === 239 /* DoStatement */ + || kind === 244 /* ContinueStatement */ + || kind === 245 /* BreakStatement */ + || kind === 246 /* ReturnStatement */ + || kind === 250 /* ThrowStatement */ + || kind === 252 /* DebuggerStatement */ + || kind === 166 /* PropertyDeclaration */ + || kind === 258 /* TypeAliasDeclaration */ + || kind === 265 /* ImportDeclaration */ + || kind === 264 /* ImportEqualsDeclaration */ + || kind === 271 /* ExportDeclaration */ + || kind === 263 /* NamespaceExportDeclaration */ + || kind === 270 /* ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); @@ -123641,7 +125956,7 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 238 /* DoStatement */) { + if (node.kind === 239 /* DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); @@ -123964,6 +126279,21 @@ var ts; return ts.createTextSpanFromBounds(startPosition, endPosition === undefined ? startPosition : endPosition); } ts.getRefactorContextSpan = getRefactorContextSpan; + /* @internal */ + function getFixableErrorSpanExpression(sourceFile, span) { + var token = getTokenAtPosition(sourceFile, span.start); + // Checker has already done work to determine that await might be possible, and has attached + // related info to the node, so start by finding the expression that exactly matches up + // with the diagnostic range. + var expression = ts.findAncestor(token, function (node) { + if (node.getStart(sourceFile) < span.start || node.getEnd() > ts.textSpanEnd(span)) { + return "quit"; + } + return ts.isExpression(node) && textSpansEqual(span, createTextSpanFromNode(node, sourceFile)); + }); + return expression; + } + ts.getFixableErrorSpanExpression = getFixableErrorSpanExpression; function mapOneOrMany(valueOrArray, f, resultSelector) { if (resultSelector === void 0) { resultSelector = ts.identity; } return valueOrArray ? ts.isArray(valueOrArray) ? resultSelector(ts.map(valueOrArray, f)) : f(valueOrArray, 0) : undefined; @@ -124056,6 +126386,16 @@ var ts; return decisionFromFile !== null && decisionFromFile !== void 0 ? decisionFromFile : program.usesUriStyleNodeCoreModules; } ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules; + function getNewLineKind(newLineCharacter) { + return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + } + ts.getNewLineKind = getNewLineKind; + function diagnosticToString(diag) { + return ts.isArray(diag) + ? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1)) + : ts.getLocaleSpecificMessage(diag); + } + ts.diagnosticToString = diagnosticToString; // #endregion })(ts || (ts = {})); /*@internal*/ @@ -124095,19 +126435,24 @@ var ts; } 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) + // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`. + // 2. 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`.) + // 3. Otherwise, we have a default/namespace import that can be imported by any name, and + // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to + // get a better name. + var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol) ? ts.unescapeLeadingUnderscores(symbolTableKey) : ts.getNameForExportedSymbol(namedSymbol, scriptTarget); var moduleName = ts.stripQuotes(moduleSymbol.name); var id = exportInfoId++; + var target = ts.skipAlias(symbol, checker); 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), { + exportInfo.add(key(importedName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), { id: id, symbolTableKey: symbolTableKey, symbolName: importedName, @@ -124115,16 +126460,16 @@ var ts; moduleFile: moduleFile, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: exportKind, - targetFlags: ts.skipAlias(symbol, checker).flags, + targetFlags: target.flags, isFromPackageJson: isFromPackageJson, symbol: storedSymbol, moduleSymbol: storedModuleSymbol, }); }, - get: function (importingFile, importedName, symbol, moduleName, checker) { + get: function (importingFile, key) { if (importingFile !== usableByFileName) return; - var result = exportInfo.get(key(importedName, symbol, moduleName, checker)); + var result = exportInfo.get(key); return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo); }, forEach: function (importingFile, action) { @@ -124132,7 +126477,7 @@ var ts; return; exportInfo.forEach(function (info, key) { var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName; - action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName); + action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName, key); }); }, releaseSymbols: function () { @@ -124197,26 +126542,16 @@ var ts; 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 key(importedName, symbol, ambientModuleName, checker) { + var moduleKey = ambientModuleName || ""; + return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey; } function parseKey(key) { var symbolName = key.substring(0, key.indexOf("|")); var moduleKey = key.substring(key.lastIndexOf("|") + 1); - var ambientModuleName = moduleKey === "/" ? undefined : moduleKey; + 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; - } function fileIsGlobalOnly(file) { return !file.commonJsModuleIndicator && !file.externalModuleIndicator && !file.moduleAugmentations && !file.ambientModuleNames; } @@ -124226,7 +126561,7 @@ var ts; } var oldFileStatementIndex = -1; var newFileStatementIndex = -1; - var _loop_1 = function (ambientModuleName) { + var _loop_2 = function (ambientModuleName) { var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); @@ -124236,9 +126571,9 @@ var ts; }; for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { var ambientModuleName = _a[_i]; - var state_1 = _loop_1(ambientModuleName); - if (typeof state_1 === "object") - return state_1.value; + var state_2 = _loop_2(ambientModuleName); + if (typeof state_2 === "object") + return state_2.value; } return true; } @@ -124338,7 +126673,7 @@ var ts; 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)) { + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, scriptTarget, checker); } }); @@ -124503,11 +126838,11 @@ var ts; angleBracketStack--; } break; - case 129 /* AnyKeyword */: - case 148 /* StringKeyword */: - case 145 /* NumberKeyword */: - case 132 /* BooleanKeyword */: - case 149 /* SymbolKeyword */: + case 130 /* AnyKeyword */: + case 149 /* StringKeyword */: + case 146 /* NumberKeyword */: + case 133 /* BooleanKeyword */: + case 150 /* 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, @@ -124696,9 +127031,9 @@ var ts; return true; } switch (keyword2) { - case 135 /* GetKeyword */: - case 147 /* SetKeyword */: - case 133 /* ConstructorKeyword */: + case 136 /* GetKeyword */: + case 148 /* SetKeyword */: + case 134 /* ConstructorKeyword */: case 124 /* StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: @@ -124842,13 +127177,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 259 /* ModuleDeclaration */: - case 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: - case 254 /* FunctionDeclaration */: - case 224 /* ClassExpression */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 260 /* ModuleDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 255 /* FunctionDeclaration */: + case 225 /* ClassExpression */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -125070,46 +127405,46 @@ var ts; pos = tag.tagName.end; var commentStart = tag.tagName.end; switch (tag.kind) { - case 335 /* JSDocParameterTag */: + case 338 /* 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 342 /* JSDocPropertyTag */: + case 345 /* JSDocPropertyTag */: var prop = tag; commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 339 /* JSDocTemplateTag */: + case 342 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; commentStart = tag.typeParameters.end; break; - case 340 /* JSDocTypedefTag */: + case 343 /* JSDocTypedefTag */: var type = tag; - 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; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 307 /* 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 333 /* JSDocCallbackTag */: + case 336 /* JSDocCallbackTag */: commentStart = tag.typeExpression.end; break; - case 338 /* JSDocTypeTag */: + case 341 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = tag.typeExpression.end; break; - case 337 /* JSDocThisTag */: - case 334 /* JSDocEnumTag */: + case 340 /* JSDocThisTag */: + case 337 /* JSDocEnumTag */: commentStart = tag.typeExpression.end; break; - case 336 /* JSDocReturnTag */: + case 339 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; - case 341 /* JSDocSeeTag */: + case 344 /* JSDocSeeTag */: commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; - case 323 /* JSDocAugmentsTag */: - case 324 /* JSDocImplementsTag */: + case 326 /* JSDocAugmentsTag */: + case 327 /* JSDocImplementsTag */: commentStart = tag.class.end; break; } @@ -125266,22 +127601,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 278 /* JsxOpeningElement */: + case 279 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 279 /* JsxClosingElement */: + case 280 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 277 /* JsxSelfClosingElement */: + case 278 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 283 /* JsxAttribute */: + case 284 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -125310,17 +127645,17 @@ var ts; var parent = token.parent; if (tokenKind === 63 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 252 /* VariableDeclaration */ || - parent.kind === 165 /* PropertyDeclaration */ || - parent.kind === 162 /* Parameter */ || - parent.kind === 283 /* JsxAttribute */) { + if (parent.kind === 253 /* VariableDeclaration */ || + parent.kind === 166 /* PropertyDeclaration */ || + parent.kind === 163 /* Parameter */ || + parent.kind === 284 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 219 /* BinaryExpression */ || - parent.kind === 217 /* PrefixUnaryExpression */ || - parent.kind === 218 /* PostfixUnaryExpression */ || - parent.kind === 220 /* ConditionalExpression */) { + if (parent.kind === 220 /* BinaryExpression */ || + parent.kind === 218 /* PrefixUnaryExpression */ || + parent.kind === 219 /* PostfixUnaryExpression */ || + parent.kind === 221 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -125333,7 +127668,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 283 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 284 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -125349,32 +127684,32 @@ var ts; else if (tokenKind === 79 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 161 /* TypeParameter */: + case 162 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 256 /* InterfaceDeclaration */: + case 257 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 162 /* Parameter */: + case 163 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -125476,13 +127811,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 259 /* ModuleDeclaration */: - case 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: - case 254 /* FunctionDeclaration */: - case 224 /* ClassExpression */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 260 /* ModuleDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 255 /* FunctionDeclaration */: + case 225 /* ClassExpression */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -125628,25 +127963,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([ - [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 */] + [253 /* VariableDeclaration */, 7 /* variable */], + [163 /* Parameter */, 6 /* parameter */], + [166 /* PropertyDeclaration */, 9 /* property */], + [260 /* ModuleDeclaration */, 3 /* namespace */], + [259 /* EnumDeclaration */, 1 /* enum */], + [297 /* EnumMember */, 8 /* enumMember */], + [256 /* ClassDeclaration */, 0 /* class */], + [168 /* MethodDeclaration */, 11 /* member */], + [255 /* FunctionDeclaration */, 10 /* function */], + [212 /* FunctionExpression */, 10 /* function */], + [167 /* MethodSignature */, 11 /* member */], + [171 /* GetAccessor */, 9 /* property */], + [172 /* SetAccessor */, 9 /* property */], + [165 /* PropertySignature */, 9 /* property */], + [257 /* InterfaceDeclaration */, 2 /* interface */], + [258 /* TypeAliasDeclaration */, 5 /* type */], + [162 /* TypeParameter */, 4 /* typeParameter */], + [294 /* PropertyAssignment */, 9 /* property */], + [295 /* ShorthandPropertyAssignment */, 9 /* property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -125658,7 +127993,7 @@ var ts; (function (Completions) { var StringCompletions; (function (StringCompletions) { - function getStringLiteralCompletions(sourceFile, position, contextToken, checker, options, host, log, preferences) { + function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) { if (ts.isInReferenceComment(sourceFile, position)) { var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host); return entries && convertPathCompletions(entries); @@ -125666,12 +128001,12 @@ var ts; if (ts.isInString(sourceFile, position, contextToken)) { if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; - var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); - return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, options, preferences); + var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program.getTypeChecker(), options, host, preferences); + return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences); } } StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; - function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, options, preferences) { + function convertStringLiteralCompletions(completion, contextToken, sourceFile, host, program, log, options, preferences) { if (completion === undefined) { return undefined; } @@ -125681,7 +128016,7 @@ var ts; return convertPathCompletions(completion.paths); case 1 /* Properties */: { var entries = []; - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } case 2 /* Types */: { @@ -125738,6 +128073,12 @@ var ts; case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; case ".ts" /* Ts */: return ".ts" /* tsModifier */; case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; + case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */; + case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */; + case ".mts" /* Mts */: return ".mts" /* mtsModifier */; + case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */; + case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */; + case ".cts" /* Cts */: return ".cts" /* ctsModifier */; case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); case undefined: return "" /* none */; default: @@ -125753,10 +128094,10 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 194 /* LiteralType */: { + case 195 /* LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 176 /* TypeReference */: { + case 177 /* TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { @@ -125764,7 +128105,7 @@ var ts; } return undefined; } - case 192 /* IndexedAccessType */: + case 193 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -125776,9 +128117,9 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 198 /* ImportType */: + case 199 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; - case 185 /* UnionType */: { + case 186 /* UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } @@ -125790,7 +128131,7 @@ var ts; return undefined; } } - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -125807,7 +128148,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 205 /* ElementAccessExpression */: { + case 206 /* ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -125820,8 +128161,8 @@ var ts; } return undefined; } - case 206 /* CallExpression */: - case 207 /* NewExpression */: + case 207 /* CallExpression */: + case 208 /* 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 @@ -125830,9 +128171,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `require(""` or `import("")`) - case 264 /* ImportDeclaration */: - case 270 /* ExportDeclaration */: - case 275 /* ExternalModuleReference */: + case 265 /* ImportDeclaration */: + case 271 /* ExportDeclaration */: + case 276 /* 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*/"); @@ -125851,9 +128192,9 @@ var ts; } function walkUpParentheses(node) { switch (node.kind) { - case 189 /* ParenthesizedType */: + case 190 /* ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -125927,15 +128268,18 @@ var ts; var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue)) - ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption()) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + function getIncludeExtensionOption() { + var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; + return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + } } function getExtensionOptions(compilerOptions, includeExtensionsOption) { if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; } - return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensionsOption: includeExtensionsOption }; + return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption }; } - function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) { - var includeExtensions = preferences.importModuleSpecifierEnding === "js" ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) { var extensionOptions = getExtensionOptions(compilerOptions, includeExtensions); if (compilerOptions.rootDirs) { return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); @@ -125946,8 +128290,8 @@ var ts; } function getSupportedExtensionsForModuleResolution(compilerOptions) { var extensions = ts.getSupportedExtensions(compilerOptions); - return compilerOptions.resolveJsonModule && ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ? - extensions.concat(".json" /* Json */) : + return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs ? + ts.getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) : extensions; } /** @@ -126021,11 +128365,11 @@ var ts; } var foundFileName = void 0; var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings()); - if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIs(filePath, ".json" /* Json */)) { + if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) { foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath)); foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); } - else if (includeExtensionsOption === 2 /* ModuleSpecifierCompletion */ && outputExtension) { + else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) { foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension); foundFiles.set(foundFileName, outputExtension); } @@ -126071,7 +128415,7 @@ var ts; continue; var patterns = paths[path]; if (patterns) { - var _loop_2 = function (name, kind, extension) { + var _loop_3 = function (name, kind, extension) { // Path mappings may provide a duplicate way to get to something we've already added, so don't add again. if (!result.some(function (entry) { return entry.name === name; })) { result.push(nameAndKind(name, kind, extension)); @@ -126079,7 +128423,7 @@ var ts; }; for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) { var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension; - _loop_2(name, kind, extension); + _loop_3(name, kind, extension); } } } @@ -126114,7 +128458,7 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_3 = function (moduleName) { + var _loop_4 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); @@ -126122,7 +128466,7 @@ var ts; }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { var moduleName = _c[_b]; - _loop_3(moduleName); + _loop_4(moduleName); } } if (!foundGlobal) { @@ -126398,6 +128742,8 @@ var ts; (function (CompletionSource) { /** Completions that require `this.` insertion text */ CompletionSource["ThisProperty"] = "ThisProperty/"; + /** Auto-import that comes attached to a class member snippet */ + CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/"; })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {})); var SymbolOriginInfoKind; (function (SymbolOriginInfoKind) { @@ -126444,6 +128790,7 @@ var ts; KeywordCompletionFilters[KeywordCompletionFilters["FunctionLikeBodyKeywords"] = 5] = "FunctionLikeBodyKeywords"; KeywordCompletionFilters[KeywordCompletionFilters["TypeAssertionKeywords"] = 6] = "TypeAssertionKeywords"; KeywordCompletionFilters[KeywordCompletionFilters["TypeKeywords"] = 7] = "TypeKeywords"; + KeywordCompletionFilters[KeywordCompletionFilters["TypeKeyword"] = 8] = "TypeKeyword"; KeywordCompletionFilters[KeywordCompletionFilters["Last"] = 7] = "Last"; })(KeywordCompletionFilters || (KeywordCompletionFilters = {})); var GlobalsSearch; @@ -126505,7 +128852,6 @@ var ts; } // 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)) { @@ -126517,7 +128863,7 @@ var ts; else { incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.clear(); } - var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken, typeChecker, compilerOptions, host, log, preferences); + var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken, compilerOptions, host, program, log, preferences); if (stringCompletions) { return stringCompletions; } @@ -126531,7 +128877,7 @@ var ts; } switch (completionData.kind) { case 0 /* Data */: - var response = completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences); + var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences); if (response === null || response === void 0 ? void 0 : response.isIncomplete) { incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response); } @@ -126545,26 +128891,25 @@ var ts; case 3 /* JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); case 4 /* Keywords */: - return specificKeywordCompletionInfo(completionData.keywords); + return specificKeywordCompletionInfo(completionData.keywordCompletions, completionData.isNewIdentifierLocation); default: return ts.Debug.assertNever(completionData); } } Completions.getCompletionsAtPosition = getCompletionsAtPosition; + function completionEntryDataIsResolved(data) { + return !!(data === null || data === void 0 ? void 0 : data.moduleSpecifier); + } 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) { + if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) { // Not an auto import or already resolved; keep as is return entry; } @@ -126572,8 +128917,8 @@ var ts; // 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 origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin; + var info = exportMap.get(file.path, entry.data.exportMapKey); var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name))); if (!result) return entry; @@ -126596,25 +128941,41 @@ var ts; function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } - function specificKeywordCompletionInfo(keywords) { + function keywordToCompletionEntry(keyword) { + return { + name: ts.tokenToString(keyword), + kind: "keyword" /* keyword */, + kindModifiers: "" /* none */, + sortText: SortText.GlobalsOrKeywords, + }; + } + function specificKeywordCompletionInfo(entries, isNewIdentifierLocation) { return { isGlobalCompletion: false, isMemberCompletion: false, - isNewIdentifierLocation: false, - entries: keywords.map(function (k) { return ({ - name: ts.tokenToString(k), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, - sortText: SortText.GlobalsOrKeywords, - }); }), + isNewIdentifierLocation: isNewIdentifierLocation, + entries: entries.slice(), + }; + } + function keywordCompletionData(keywordFilters, filterOutTsOnlyKeywords, isNewIdentifierLocation) { + return { + kind: 4 /* Keywords */, + keywordCompletions: getKeywordCompletions(keywordFilters, filterOutTsOnlyKeywords), + isNewIdentifierLocation: isNewIdentifierLocation, }; } + function keywordFiltersFromSyntaxKind(keywordCompletion) { + switch (keywordCompletion) { + case 151 /* TypeKeyword */: return 8 /* TypeKeyword */; + default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters"); + } + } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts 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, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; + function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) { + var symbols = completionData.symbols, contextToken = completionData.contextToken, 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); @@ -126625,15 +128986,15 @@ 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, symbolToSortTextIdMap); - getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); + getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217 } else { if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap); + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), 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; })); @@ -126674,12 +129035,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 279 /* JsxClosingElement */: + case 280 /* JsxClosingElement */: return true; case 43 /* SlashToken */: case 31 /* GreaterThanToken */: case 79 /* Identifier */: - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return false; default: return "quit"; @@ -126739,14 +129100,16 @@ var ts; function createCompletionEntryForLiteral(sourceFile, preferences, literal) { return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; } - function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences) { - var _a; + function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) { + var _a, _b; var insertText; - var replacementSpan = ts.getReplacementSpanForContextToken(contextToken); + var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken); var data; var isSnippet; + var source = getSourceFromOrigin(origin); var sourceDisplay; var hasAction; + var typeChecker = program.getTypeChecker(); var insertQuestionDot = origin && originIsNullableMember(origin); var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { @@ -126793,10 +129156,44 @@ var ts; if (originIsResolvedExport(origin)) { sourceDisplay = [ts.textPart(origin.moduleSpecifier)]; if (importCompletionNode) { - (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan); + (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan); isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; } } + if (preferences.includeCompletionsWithClassMemberSnippets && + preferences.includeCompletionsWithInsertText && + completionKind === 3 /* MemberLike */ && + isClassLikeMemberCompletion(symbol, location)) { + var importAdder = void 0; + (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder); + if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) { + hasAction = true; + source = CompletionSource.ClassMemberSnippet; + } + } + var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location); + if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") { + var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces"; + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); + // If is boolean like or undefined, don't return a snippet we want just to return the completion. + if (preferences.jsxAttributeCompletionStyle === "auto" + && !(type.flags & 528 /* BooleanLike */) + && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) { + if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) { + // If is string like or undefined use quotes + insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1"); + isSnippet = true; + } + else { + // Use braces for everything else + useBraces_1 = true; + } + } + if (useBraces_1) { + insertText = ts.escapeSnippetText(name) + "={$1}"; + isSnippet = true; + } + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -126813,10 +129210,10 @@ var ts; // entries (like JavaScript identifier entries). return { name: name, - kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location), + kind: kind, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), sortText: sortText, - source: getSourceFromOrigin(origin), + source: source, hasAction: hasAction ? true : undefined, isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined, insertText: insertText, @@ -126828,30 +129225,243 @@ var ts; data: data, }; } - function originToCompletionEntryData(origin) { + function isClassLikeMemberCompletion(symbol, location) { + // TODO: support JS files. + if (ts.isInJSFile(location)) { + return false; + } + // Completion symbol must be for a class member. + var memberFlags = 106500 /* ClassMember */ + & 900095 /* EnumMemberExcludes */; + /* In + `class C { + | + }` + `location` is a class-like declaration. + In + `class C { + m| + }` + `location` is an identifier, + `location.parent` is a class element declaration, + and `location.parent.parent` is a class-like declaration. + In + `abstract class C { + abstract + abstract m| + }` + `location` is a syntax list (with modifiers as children), + and `location.parent` is a class-like declaration. + */ + return !!(symbol.flags & memberFlags) && + (ts.isClassLike(location) || + (location.parent && + location.parent.parent && + ts.isClassElement(location.parent) && + location === location.parent.name && + ts.isClassLike(location.parent.parent)) || + (location.parent && + ts.isSyntaxList(location) && + ts.isClassLike(location.parent))); + } + function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) { + var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike); + if (!classLikeDeclaration) { + return { insertText: name }; + } + var isSnippet; + var insertText = name; + var checker = program.getTypeChecker(); + var sourceFile = location.getSourceFile(); + var printer = createSnippetPrinter({ + removeComments: true, + module: options.module, + target: options.target, + omitTrailingSemicolon: false, + newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))), + }); + var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host); + var body; + if (preferences.includeCompletionsWithSnippetText) { + isSnippet = true; + // We are adding a tabstop (i.e. `$0`) in the body of the suggested member, + // if it has one, so that the cursor ends up in the body once the completion is inserted. + // Note: this assumes we won't have more than one body in the completion nodes, which should be the case. + var emptyStatement = ts.factory.createExpressionStatement(ts.factory.createIdentifier("")); + ts.setSnippetElement(emptyStatement, { kind: 0 /* TabStop */, order: 0 }); + body = ts.factory.createBlock([emptyStatement], /* multiline */ true); + } + else { + body = ts.factory.createBlock([], /* multiline */ true); + } + var modifiers = 0 /* None */; + // Whether the suggested member should be abstract. + // e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`. + // Note: We are relying on checking if the context token is `abstract`, + // since other visibility modifiers (e.g. `protected`) should come *before* `abstract`. + // However, that is not true for the e.g. `override` modifier, so this check has its limitations. + var isAbstract = contextToken && isModifierLike(contextToken) === 126 /* AbstractKeyword */; + var completionNodes = []; + ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder, + // `addNewNodeForMemberSymbol` calls this callback function for each new member node + // it adds for the given member symbol. + // We store these member nodes in the `completionNodes` array. + // Note: there might be: + // - No nodes if `addNewNodeForMemberSymbol` cannot figure out a node for the member; + // - One node; + // - More than one node if the member is overloaded (e.g. a method with overload signatures). + function (node) { + var requiredModifiers = 0 /* None */; + if (isAbstract) { + requiredModifiers |= 128 /* Abstract */; + } + if (ts.isClassElement(node) + && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) { + requiredModifiers |= 16384 /* Override */; + } + var presentModifiers = 0 /* None */; + if (!completionNodes.length) { + // Omit already present modifiers from the first completion node/signature. + if (contextToken) { + presentModifiers = getPresentModifiers(contextToken); + } + // Keep track of added missing required modifiers and modifiers already present. + // This is needed when we have overloaded signatures, + // so this callback will be called for multiple nodes/signatures, + // and we need to make sure the modifiers are uniform for all nodes/signatures. + modifiers = node.modifierFlagsCache | requiredModifiers | presentModifiers; + } + node = ts.factory.updateModifiers(node, modifiers & (~presentModifiers)); + completionNodes.push(node); + }, body, 2 /* Property */, isAbstract); + if (completionNodes.length) { + insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile); + } + return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder }; + } + function getPresentModifiers(contextToken) { + var modifiers = 0 /* None */; + var contextMod; + /* + Cases supported: + In + `class C { + public abstract | + }` + `contextToken` is ``abstract`` (as an identifier), + `contextToken.parent` is property declaration, + `location` is class declaration ``class C { ... }``. + In + `class C { + protected override m| + }` + `contextToken` is ``override`` (as a keyword), + `contextToken.parent` is property declaration, + `location` is identifier ``m``, + `location.parent` is property declaration ``protected override m``, + `location.parent.parent` is class declaration ``class C { ... }``. + */ + if (contextMod = isModifierLike(contextToken)) { + modifiers |= ts.modifierToFlag(contextMod); + } + if (ts.isPropertyDeclaration(contextToken.parent)) { + modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers); + } + return modifiers; + } + function isModifierLike(node) { + if (ts.isModifier(node)) { + return node.kind; + } + if (ts.isIdentifier(node) && node.originalKeywordKind && ts.isModifierKind(node.originalKeywordKind)) { + return node.originalKeywordKind; + } + return undefined; + } + function createSnippetPrinter(printerOptions) { + var printer = ts.createPrinter(printerOptions); + var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions)); + var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } }); return { + printSnippetList: printSnippetList, + }; + /* Snippet-escaping version of `printer.printList`. */ + function printSnippetList(format, list, sourceFile) { + writer.clear(); + printer.writeList(format, list, sourceFile, writer); + return writer.getText(); + } + } + function originToCompletionEntryData(origin) { + var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name); + var isPackageJsonImport = origin.isFromPackageJson ? true : undefined; + if (originIsResolvedExport(origin)) { + var resolvedData = { + exportName: origin.exportName, + moduleSpecifier: origin.moduleSpecifier, + ambientModuleName: ambientModuleName, + fileName: origin.fileName, + isPackageJsonImport: isPackageJsonImport, + }; + return resolvedData; + } + var unresolvedData = { exportName: origin.exportName, + exportMapKey: origin.exportMapKey, fileName: origin.fileName, ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name), isPackageJsonImport: origin.isFromPackageJson ? true : undefined, - moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined, }; + return unresolvedData; + } + function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) { + var isDefaultExport = data.exportName === "default" /* Default */; + var isFromPackageJson = !!data.isPackageJsonImport; + if (completionEntryDataIsResolved(data)) { + var resolvedOrigin = { + kind: 32 /* ResolvedExport */, + exportName: data.exportName, + moduleSpecifier: data.moduleSpecifier, + symbolName: completionName, + fileName: data.fileName, + moduleSymbol: moduleSymbol, + isDefaultExport: isDefaultExport, + isFromPackageJson: isFromPackageJson, + }; + return resolvedOrigin; + } + var unresolvedOrigin = { + kind: 4 /* Export */, + exportName: data.exportName, + exportMapKey: data.exportMapKey, + symbolName: completionName, + fileName: data.fileName, + moduleSymbol: moduleSymbol, + isDefaultExport: isDefaultExport, + isFromPackageJson: isFromPackageJson, + }; + return unresolvedOrigin; } - function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences) { + function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, contextToken, origin, useSemicolons, options, preferences) { + var _a, _b, _c; var sourceFile = importCompletionNode.getSourceFile(); - var replacementSpan = ts.createTextSpanFromNode(importCompletionNode, sourceFile); + var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); var exportKind = origin.isDefaultExport ? 1 /* Default */ : origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : 0 /* Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true); + var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly); + var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken); + var topLevelTypeOnlyText = isTopLevelTypeOnly ? " " + ts.tokenToString(151 /* TypeKeyword */) + " " : " "; + var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(151 /* TypeKeyword */) + " " : ""; 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 + " from " + quotedModuleSpecifier + suffix }; - case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import { " + name + tabStop + " } from " + quotedModuleSpecifier + suffix }; + case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; + case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix }; + case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix }; } } function quotePropertyName(sourceFile, preferences, name) { @@ -126875,11 +129485,12 @@ 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, symbolToSortTextIdMap) { + function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, 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); + var typeChecker = program.getTypeChecker(); // Tracks unique names. // Value is set to false for global variables or completions from external module exports, because we can have multiple of those; // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports. @@ -126895,7 +129506,7 @@ var ts; var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; 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); + var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind); if (!entry) { continue; } @@ -126988,11 +129599,13 @@ var ts; if (entryId.data) { var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host); if (autoImport) { + var _a = getRelevantTokens(position, sourceFile), contextToken_1 = _a.contextToken, previousToken_1 = _a.previousToken; return { type: "symbol", symbol: autoImport.symbol, location: ts.getTouchingPropertyName(sourceFile, position), - previousToken: ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined), + previousToken: previousToken_1, + contextToken: contextToken_1, isJsxInitializer: false, isTypeOnlyLocation: false, origin: autoImport.origin, @@ -127007,7 +129620,7 @@ var ts; if (completionData.kind !== 0 /* Data */) { return { type: "request", request: completionData }; } - var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; + var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; var literal = ts.find(literals, function (l) { return completionNameForLiteral(sourceFile, preferences, l) === entryId.name; }); if (literal !== undefined) return { type: "literal", literal: literal }; @@ -127017,16 +129630,16 @@ var ts; // completion entry. return ts.firstDefined(symbols, function (symbol, index) { var origin = symbolToOriginInfoMap[index]; - var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind, completionData.isJsxIdentifierExpected); - return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source - ? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } + var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); + return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ || getSourceFromOrigin(origin) === entryId.source) + ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; }) || { type: "none" }; } function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); - var name = entryId.name; + var name = entryId.name, source = entryId.source, data = entryId.data; var contextToken = ts.findPrecedingToken(position, sourceFile); if (ts.isInString(sourceFile, position, contextToken)) { return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences); @@ -127044,14 +129657,14 @@ var ts; case 3 /* JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); case 4 /* Keywords */: - return request.keywords.indexOf(ts.stringToToken(name)) > -1 ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } } case "symbol": { - var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken; - var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; + var symbol = symbolCompletion.symbol, location = symbolCompletion.location, contextToken_2 = symbolCompletion.contextToken, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken_2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -127080,21 +129693,34 @@ 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, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) { + function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) { if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) { - var _a = getRelevantTokens(position, sourceFile), contextToken = _a.contextToken, previousToken_1 = _a.previousToken; - if (previousToken_1 && getImportCompletionNode(contextToken || previousToken_1)) { + var _a = getRelevantTokens(position, sourceFile), contextToken_3 = _a.contextToken, previousToken_2 = _a.previousToken; + if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) { // Import statement completion: 'import c|' return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] }; } } + if (source === CompletionSource.ClassMemberSnippet) { + var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken).importAdder; + if (importAdder) { + var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes); + return { + sourceDisplay: undefined, + codeActions: [{ + changes: changes, + description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]), + }], + }; + } + } 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 _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; + var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); + var _b = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions)), 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] }; } @@ -127137,11 +129763,11 @@ var ts; return ts.getContextualTypeFromParent(previousToken, checker); case 63 /* EqualsToken */: switch (parent.kind) { - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 283 /* JsxAttribute */: + case 284 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -127151,7 +129777,7 @@ var ts; case 82 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 276 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? @@ -127171,7 +129797,7 @@ var ts; } function isModuleSymbol(symbol) { var _a; - return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 300 /* SourceFile */; })); + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 303 /* SourceFile */; })); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host, cancellationToken) { var typeChecker = program.getTypeChecker(); @@ -127222,11 +129848,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 304 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 307 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 342 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 345 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -127246,6 +129872,7 @@ var ts; start = ts.timestamp(); // 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 isJsOnlyLocation = !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile); var tokens = getRelevantTokens(position, sourceFile); var previousToken = tokens.previousToken; var contextToken = tokens.contextToken; @@ -127263,29 +129890,41 @@ var ts; var isJsxIdentifierExpected = false; var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); + var keywordFilters = 0 /* None */; + var isNewIdentifierLocation = false; if (contextToken) { - var importCompletionCandidate = getImportCompletionNode(contextToken); - if (importCompletionCandidate === 154 /* FromKeyword */) { - return { kind: 4 /* Keywords */, keywords: [154 /* FromKeyword */] }; + var importStatementCompletion = getImportStatementCompletionInfo(contextToken); + isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation; + if (importStatementCompletion.keywordCompletion) { + if (importStatementCompletion.isKeywordOnlyCompletion) { + return { + kind: 4 /* Keywords */, + keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)], + isNewIdentifierLocation: isNewIdentifierLocation, + }; + } + keywordFilters = keywordFiltersFromSyntaxKind(importStatementCompletion.keywordCompletion); } - // 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 - // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients - // to opt in with the `includeCompletionsForImportStatements` user preference. - if (importCompletionCandidate && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { - importCompletionNode = importCompletionCandidate; + if (importStatementCompletion.replacementNode && preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { + // 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 + // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients + // to opt in with the `includeCompletionsForImportStatements` user preference. + importCompletionNode = importStatementCompletion.replacementNode; } // Bail out if this is a known invalid completion location if (!importCompletionNode && isCompletionListBlocker(contextToken)) { log("Returning an empty list because completion was requested in an invalid position."); - return undefined; + return keywordFilters + ? keywordCompletionData(keywordFilters, isJsOnlyLocation, isNewIdentifierDefinitionLocation()) + : undefined; } var parent = contextToken.parent; if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { isRightOfDot = contextToken.kind === 24 /* DotToken */; isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert); @@ -127301,16 +129940,16 @@ var ts; return undefined; } break; - case 159 /* QualifiedName */: + case 160 /* QualifiedName */: node = parent.left; break; - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: node = parent.name; break; - case 198 /* ImportType */: + case 199 /* ImportType */: node = parent; break; - case 229 /* MetaProperty */: + case 230 /* MetaProperty */: node = parent.getFirstToken(sourceFile); ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */); break; @@ -127324,7 +129963,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 === 204 /* PropertyAccessExpression */) { + if (parent && parent.kind === 205 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -127332,46 +129971,46 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 276 /* JsxElement */ || currentToken.parent.kind === 278 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 277 /* JsxElement */ || currentToken.parent.kind === 279 /* JsxOpeningElement */) { location = currentToken; } break; case 43 /* SlashToken */: - if (currentToken.parent.kind === 277 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 278 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 279 /* JsxClosingElement */: + case 280 /* JsxClosingElement */: if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 277 /* JsxSelfClosingElement */: - case 276 /* JsxElement */: - case 278 /* JsxOpeningElement */: + case 278 /* JsxSelfClosingElement */: + case 277 /* JsxElement */: + case 279 /* JsxOpeningElement */: isJsxIdentifierExpected = true; if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 286 /* JsxExpression */: - case 285 /* JsxSpreadAttribute */: + case 287 /* JsxExpression */: + case 286 /* JsxSpreadAttribute */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 283 /* JsxAttribute */: + case 284 /* JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -127398,10 +130037,8 @@ var ts; } var semanticStart = ts.timestamp(); 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 = []; @@ -127435,12 +130072,14 @@ var ts; // global symbols in scope. These results should be valid for either language as // the set of symbols that can be referenced from this location. if (!tryGetGlobalSymbols()) { - return undefined; + return keywordFilters + ? keywordCompletionData(keywordFilters, isJsOnlyLocation, isNewIdentifierLocation) + : undefined; } } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); var contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker); - var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() ? t.value : undefined; }); + var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : undefined; }); var recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker); return { kind: 0 /* Data */, @@ -127455,6 +130094,7 @@ var ts; symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, + contextToken: contextToken, isJsxInitializer: isJsxInitializer, insideJsDocTagTypeExpression: insideJsDocTagTypeExpression, symbolToSortTextIdMap: symbolToSortTextIdMap, @@ -127465,11 +130105,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 335 /* JSDocParameterTag */: - case 342 /* JSDocPropertyTag */: - case 336 /* JSDocReturnTag */: - case 338 /* JSDocTypeTag */: - case 340 /* JSDocTypedefTag */: + case 338 /* JSDocParameterTag */: + case 345 /* JSDocPropertyTag */: + case 339 /* JSDocReturnTag */: + case 341 /* JSDocTypeTag */: + case 343 /* JSDocTypedefTag */: return true; default: return false; @@ -127514,7 +130154,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 !== 300 /* SourceFile */ && d.kind !== 259 /* ModuleDeclaration */ && d.kind !== 258 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 303 /* SourceFile */ && d.kind !== 260 /* ModuleDeclaration */ && d.kind !== 259 /* EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -127562,7 +130202,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 198 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 199 /* 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 @@ -127592,6 +130232,7 @@ var ts; } } function addPropertySymbol(symbol, insertAwait, insertQuestionDot) { + var _a; // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -127605,19 +130246,33 @@ var ts; var index = symbols.length; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; - if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol)) { + if (!moduleSymbol || + !ts.isExternalModuleSymbol(moduleSymbol) || + typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) { symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; } else { - var origin = { - kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), - moduleSymbol: moduleSymbol, - isDefaultExport: false, - symbolName: firstAccessibleSymbol.name, - exportName: firstAccessibleSymbol.name, - fileName: ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? ts.cast(moduleSymbol.valueDeclaration, ts.isSourceFile).fileName : undefined, - }; - symbolToOriginInfoMap[index] = origin; + var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined; + var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{ + exportKind: 0 /* Named */, + moduleFileName: fileName, + isFromPackageJson: false, + moduleSymbol: moduleSymbol, + symbol: firstAccessibleSymbol, + targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags, + }], sourceFile, program, host, preferences) || {}).moduleSpecifier; + if (moduleSpecifier) { + var origin = { + kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + moduleSymbol: moduleSymbol, + isDefaultExport: false, + symbolName: firstAccessibleSymbol.name, + exportName: firstAccessibleSymbol.name, + fileName: fileName, + moduleSpecifier: moduleSpecifier, + }; + symbolToOriginInfoMap[index] = origin; + } } } else if (preferences.includeCompletionsWithInsertText) { @@ -127746,7 +130401,7 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 300 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* 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++) { @@ -127774,21 +130429,21 @@ var ts; // If not already a module, must have modules enabled. if (!preferences.includeCompletionsForModuleExports) return false; - // If already using ES6 modules, OK to continue using them. + // If already using ES modules, OK to continue using them. if (sourceFile.externalModuleIndicator || sourceFile.commonJsModuleIndicator) return true; // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK. - if (ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) + if (ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) return true; // If some file is using ES6 modules, assume that it's OK to add more. return ts.programContainsModules(program); } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 300 /* SourceFile */: - case 221 /* TemplateExpression */: - case 286 /* JsxExpression */: - case 233 /* Block */: + case 303 /* SourceFile */: + case 222 /* TemplateExpression */: + case 287 /* JsxExpression */: + case 234 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -127796,6 +130451,7 @@ var ts; } function isTypeOnlyCompletion() { return insideJsDocTagTypeExpression + || !!importCompletionNode && ts.isTypeOnlyImportOrExportDeclaration(location.parent) || !isContextTokenValueLocation(contextToken) && (ts.isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker) || ts.isPartOfTypeNode(location) @@ -127804,28 +130460,28 @@ var ts; function isContextTokenValueLocation(contextToken) { return contextToken && ((contextToken.kind === 112 /* TypeOfKeyword */ && - (contextToken.parent.kind === 179 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || - (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 175 /* TypePredicate */)); + (contextToken.parent.kind === 180 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 176 /* TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 58 /* ColonToken */: - return parentKind === 165 /* PropertyDeclaration */ || - parentKind === 164 /* PropertySignature */ || - parentKind === 162 /* Parameter */ || - parentKind === 252 /* VariableDeclaration */ || + return parentKind === 166 /* PropertyDeclaration */ || + parentKind === 165 /* PropertySignature */ || + parentKind === 163 /* Parameter */ || + parentKind === 253 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 63 /* EqualsToken */: - return parentKind === 257 /* TypeAliasDeclaration */; + return parentKind === 258 /* TypeAliasDeclaration */; case 127 /* AsKeyword */: - return parentKind === 227 /* AsExpression */; + return parentKind === 228 /* AsExpression */; case 29 /* LessThanToken */: - return parentKind === 176 /* TypeReference */ || - parentKind === 209 /* TypeAssertionExpression */; + return parentKind === 177 /* TypeReference */ || + parentKind === 210 /* TypeAssertionExpression */; case 94 /* ExtendsKeyword */: - return parentKind === 161 /* TypeParameter */; + return parentKind === 162 /* TypeParameter */; } } return false; @@ -127840,13 +130496,19 @@ var ts; // Asking for completion details for an item that is not an auto-import return; } + // import { type | -> token text should be blank + var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken + && importCompletionNode + && couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken); + var lowerCaseTokenText = isAfterTypeOnlyImportSpecifierModifier ? "" : + previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : + ""; 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.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) { + exportInfo.forEach(sourceFile.path, function (info, symbolName, isFromAmbientModule, exportMapKey) { if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings()))) return; if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) @@ -127871,6 +130533,7 @@ var ts; kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, moduleSpecifier: moduleSpecifier, symbolName: symbolName, + exportMapKey: exportMapKey, exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name, fileName: exportInfo_1.moduleFileName, isDefaultExport: isDefaultExport, @@ -127931,7 +130594,7 @@ var ts; return true; } if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 278 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 279 /* JsxOpeningElement */) { // Two possibilities: // 1.
/**/ // - contextToken: GreaterThanToken (before cursor) @@ -127941,10 +130604,10 @@ var ts; // - contextToken: GreaterThanToken (before cursor) // - location: GreaterThanToken (after cursor) // - same parent (JSXOpeningElement) - return location.parent.kind !== 278 /* JsxOpeningElement */; + return location.parent.kind !== 279 /* JsxOpeningElement */; } - if (contextToken.parent.kind === 279 /* JsxClosingElement */ || contextToken.parent.kind === 277 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 276 /* JsxElement */; + if (contextToken.parent.kind === 280 /* JsxClosingElement */ || contextToken.parent.kind === 278 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 277 /* JsxElement */; } } return false; @@ -127952,45 +130615,51 @@ var ts; function isNewIdentifierDefinitionLocation() { if (contextToken) { var containingNodeKind = contextToken.parent.kind; + var tokenKind = keywordForNode(contextToken); // Previous token may have been a keyword that was converted to an identifier. - switch (keywordForNode(contextToken)) { + switch (tokenKind) { case 27 /* CommaToken */: - 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, | + return containingNodeKind === 207 /* CallExpression */ // func( a, | + || containingNodeKind === 170 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 208 /* NewExpression */ // new C(a, | + || containingNodeKind === 203 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 220 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 178 /* FunctionType */ // var x: (s: string, list| + || containingNodeKind === 204 /* ObjectLiteralExpression */; // const obj = { x, | case 20 /* OpenParenToken */: - 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 */ + return containingNodeKind === 207 /* CallExpression */ // func( | + || containingNodeKind === 170 /* Constructor */ // constructor( | + || containingNodeKind === 208 /* NewExpression */ // new C(a| + || containingNodeKind === 211 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 190 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - 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 containingNodeKind === 203 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 175 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 161 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 141 /* ModuleKeyword */: // module | + case 142 /* NamespaceKeyword */: // namespace | + case 100 /* ImportKeyword */: // import | return true; case 24 /* DotToken */: - return containingNodeKind === 259 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 260 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 255 /* ClassDeclaration */ // class A { | - || containingNodeKind === 203 /* ObjectLiteralExpression */; // const obj = { | + return containingNodeKind === 256 /* ClassDeclaration */ // class A { | + || containingNodeKind === 204 /* ObjectLiteralExpression */; // const obj = { | case 63 /* EqualsToken */: - return containingNodeKind === 252 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 219 /* BinaryExpression */; // x = a| + return containingNodeKind === 253 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 220 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 221 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 222 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 231 /* TemplateSpan */; // `aa ${10} dd ${| - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - return containingNodeKind === 165 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 232 /* TemplateSpan */; // `aa ${10} dd ${| + case 131 /* AsyncKeyword */: + return containingNodeKind === 168 /* MethodDeclaration */ // const obj = { async c|() + || containingNodeKind === 295 /* ShorthandPropertyAssignment */; // const obj = { async c| + case 41 /* AsteriskToken */: + return containingNodeKind === 168 /* MethodDeclaration */; // const obj = { * c| + } + if (isClassMemberCompletionKeyword(tokenKind)) { + return true; } } return false; @@ -128036,7 +130705,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 203 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 204 /* ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { @@ -128061,7 +130730,7 @@ var ts; } } else { - ts.Debug.assert(objectLikeContainer.kind === 199 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 200 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -128072,12 +130741,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 === 242 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 162 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 243 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 163 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 167 /* MethodDeclaration */ || rootDeclaration.parent.kind === 171 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 168 /* MethodDeclaration */ || rootDeclaration.parent.kind === 172 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -128085,14 +130754,8 @@ var ts; var typeForObject_1 = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject_1) return 2 /* Fail */; - // In a binding pattern, get only known properties (unless in the same scope). - // Everywhere else we will get all possible properties. - var containerClass_1 = ts.getContainingClass(objectLikeContainer); - typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (symbol) { - // either public - return !(ts.getDeclarationModifierFlagsFromSymbol(symbol) & 24 /* NonPublicAccessibilityModifier */) - // or we're in it - || containerClass_1 && ts.contains(typeForObject_1.symbol.declarations, containerClass_1); + typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (propertySymbol) { + return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject_1, propertySymbol); }); existingMembers = objectLikeContainer.elements; } @@ -128118,23 +130781,38 @@ var ts; * Relevant symbols are stored in the captured 'symbols' variable. */ function tryGetImportOrExportClauseCompletionSymbols() { - // `import { |` or `import { a as 0, | }` - var namedImportsOrExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) - ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : undefined; + if (!contextToken) + return 0 /* Continue */; + // `import { |` or `import { a as 0, | }` or `import { type | }` + var namedImportsOrExports = contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : + ts.isTypeKeywordTokenOrIdentifier(contextToken) ? ts.tryCast(contextToken.parent.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) return 0 /* Continue */; + // We can at least offer `type` at `import { |` + if (!ts.isTypeKeywordTokenOrIdentifier(contextToken)) { + keywordFilters = 8 /* TypeKeyword */; + } // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 267 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; - if (!moduleSpecifier) - return namedImportsOrExports.kind === 267 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + var moduleSpecifier = (namedImportsOrExports.kind === 268 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + if (!moduleSpecifier) { + isNewIdentifierLocation = true; + return namedImportsOrExports.kind === 268 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + } var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 - if (!moduleSpecifierSymbol) + if (!moduleSpecifierSymbol) { + isNewIdentifierLocation = true; return 2 /* Fail */; + } completionKind = 3 /* MemberLike */; 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 = ts.concatenate(symbols, exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); })); + var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); }); + symbols = ts.concatenate(symbols, uniques); + if (!uniques.length) { + // If there's nothing else to import, don't offer `type` either + keywordFilters = 0 /* None */; + } return 1 /* Success */; } /** @@ -128286,11 +130964,11 @@ var ts; case 30 /* LessThanSlashToken */: case 43 /* SlashToken */: 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 */)) { + case 205 /* PropertyAccessExpression */: + case 285 /* JsxAttributes */: + case 284 /* JsxAttribute */: + case 286 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 278 /* JsxSelfClosingElement */ || parent.kind === 279 /* JsxOpeningElement */)) { if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) @@ -128298,7 +130976,7 @@ var ts; } return parent; } - else if (parent.kind === 283 /* JsxAttribute */) { + else if (parent.kind === 284 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -128310,7 +130988,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 === 283 /* JsxAttribute */) || (parent.kind === 285 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 284 /* JsxAttribute */) || (parent.kind === 286 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -128320,8 +130998,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 286 /* JsxExpression */ && - parent.parent && parent.parent.kind === 283 /* JsxAttribute */) { + parent.kind === 287 /* JsxExpression */ && + parent.parent && parent.parent.kind === 284 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -128329,7 +131007,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 285 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 286 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -128349,52 +131027,60 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 252 /* VariableDeclaration */ || + return containingNodeKind === 253 /* VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 235 /* VariableStatement */ || - containingNodeKind === 258 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 236 /* VariableStatement */ || + containingNodeKind === 259 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 256 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 200 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 201 /* ArrayBindingPattern */; // var [.| case 58 /* ColonToken */: - return containingNodeKind === 201 /* BindingElement */; // var {x :html| + return containingNodeKind === 202 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 200 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 201 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 290 /* CatchClause */ || + return containingNodeKind === 291 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 258 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 259 /* EnumDeclaration */; // enum a { | case 29 /* LessThanToken */: - return containingNodeKind === 255 /* ClassDeclaration */ || // class A< | - containingNodeKind === 224 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 256 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 257 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 256 /* ClassDeclaration */ || // class A< | + containingNodeKind === 225 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 257 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 258 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 124 /* StaticKeyword */: - return containingNodeKind === 165 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + return containingNodeKind === 166 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 162 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 200 /* ArrayBindingPattern */); // var [...z| + return containingNodeKind === 163 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 201 /* ArrayBindingPattern */); // var [...z| case 123 /* PublicKeyword */: case 121 /* PrivateKeyword */: case 122 /* ProtectedKeyword */: - return containingNodeKind === 162 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + return containingNodeKind === 163 /* 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 containingNodeKind === 269 /* ImportSpecifier */ || + containingNodeKind === 274 /* ExportSpecifier */ || + containingNodeKind === 267 /* NamespaceImport */; + case 136 /* GetKeyword */: + case 148 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); + case 79 /* Identifier */: + if (containingNodeKind === 269 /* ImportSpecifier */ && + contextToken === parent.name && + contextToken.text === "type") { + // import { type | } + return false; + } + break; case 84 /* ClassKeyword */: case 92 /* EnumKeyword */: case 118 /* InterfaceKeyword */: @@ -128403,9 +131089,11 @@ var ts; case 100 /* ImportKeyword */: case 119 /* LetKeyword */: case 85 /* ConstKeyword */: - case 136 /* InferKeyword */: - case 150 /* TypeKeyword */: // type htm| + case 137 /* InferKeyword */: return true; + case 151 /* TypeKeyword */: + // import { type foo| } + return containingNodeKind !== 269 /* ImportSpecifier */; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } @@ -128430,7 +131118,7 @@ var ts; case 126 /* AbstractKeyword */: case 84 /* ClassKeyword */: case 85 /* ConstKeyword */: - case 134 /* DeclareKeyword */: + case 135 /* DeclareKeyword */: case 92 /* EnumKeyword */: case 98 /* FunctionKeyword */: case 118 /* InterfaceKeyword */: @@ -128441,7 +131129,7 @@ var ts; case 124 /* StaticKeyword */: case 113 /* VarKeyword */: return true; - case 130 /* AsyncKeyword */: + case 131 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } // If we are inside a class declaration, and `constructor` is totally not present, @@ -128450,7 +131138,7 @@ var ts; if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { return false; // Don't block completions. } - var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 165 /* PropertyDeclaration */); + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 166 /* PropertyDeclaration */); // If we are inside a class declaration and typing `constructor` after property declaration... if (ancestorPropertyDeclaraion && contextToken !== previousToken @@ -128482,7 +131170,7 @@ var ts; || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 169 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 170 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -128492,7 +131180,7 @@ var ts; return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 253 /* VariableDeclarationList */ + return node.parent.kind === 254 /* VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -128510,13 +131198,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 !== 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 */) { + if (m.kind !== 294 /* PropertyAssignment */ && + m.kind !== 295 /* ShorthandPropertyAssignment */ && + m.kind !== 202 /* BindingElement */ && + m.kind !== 168 /* MethodDeclaration */ && + m.kind !== 171 /* GetAccessor */ && + m.kind !== 172 /* SetAccessor */ && + m.kind !== 296 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -128591,10 +131279,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 !== 165 /* PropertyDeclaration */ && - m.kind !== 167 /* MethodDeclaration */ && - m.kind !== 170 /* GetAccessor */ && - m.kind !== 171 /* SetAccessor */) { + if (m.kind !== 166 /* PropertyDeclaration */ && + m.kind !== 168 /* MethodDeclaration */ && + m.kind !== 171 /* GetAccessor */ && + m.kind !== 172 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -128636,7 +131324,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 283 /* JsxAttribute */) { + if (attr.kind === 284 /* JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -128674,18 +131362,7 @@ var ts; return undefined; var isDefaultExport = data.exportName === "default" /* Default */; symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; - return { - symbol: symbol, - origin: { - kind: data.moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, - moduleSymbol: moduleSymbol, - symbolName: name, - isDefaultExport: isDefaultExport, - exportName: data.exportName, - fileName: data.fileName, - isFromPackageJson: !!data.isPackageJsonImport, - } - }; + return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) }; } function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, jsxIdentifierExpected) { var name = originIncludesSymbolName(origin) ? origin.symbolName : symbol.name; @@ -128722,7 +131399,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 81 /* FirstKeyword */; i <= 158 /* LastKeyword */; i++) { + for (var i = 81 /* FirstKeyword */; i <= 159 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -128748,11 +131425,12 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 134 /* DeclareKeyword */ - || kind === 140 /* ModuleKeyword */ - || kind === 150 /* TypeKeyword */ - || kind === 141 /* NamespaceKeyword */ - || ts.isTypeKeyword(kind) && kind !== 151 /* UndefinedKeyword */; + || kind === 135 /* DeclareKeyword */ + || kind === 141 /* ModuleKeyword */ + || kind === 151 /* TypeKeyword */ + || kind === 142 /* NamespaceKeyword */ + || kind === 126 /* AbstractKeyword */ + || ts.isTypeKeyword(kind) && kind !== 152 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -128765,6 +131443,8 @@ var ts; return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); + case 8 /* TypeKeyword */: + return kind === 151 /* TypeKeyword */; default: return ts.Debug.assertNever(keywordFilter); } @@ -128773,57 +131453,57 @@ var ts; function isTypeScriptOnlyKeyword(kind) { switch (kind) { case 126 /* AbstractKeyword */: - case 129 /* AnyKeyword */: - case 156 /* BigIntKeyword */: - case 132 /* BooleanKeyword */: - case 134 /* DeclareKeyword */: + case 130 /* AnyKeyword */: + case 157 /* BigIntKeyword */: + case 133 /* BooleanKeyword */: + case 135 /* DeclareKeyword */: case 92 /* EnumKeyword */: - case 155 /* GlobalKeyword */: + case 156 /* GlobalKeyword */: case 117 /* ImplementsKeyword */: - case 136 /* InferKeyword */: + case 137 /* 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 139 /* IsKeyword */: + case 140 /* KeyOfKeyword */: + case 141 /* ModuleKeyword */: + case 142 /* NamespaceKeyword */: + case 143 /* NeverKeyword */: + case 146 /* NumberKeyword */: + case 147 /* ObjectKeyword */: + case 158 /* 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 */: + case 144 /* ReadonlyKeyword */: + case 149 /* StringKeyword */: + case 150 /* SymbolKeyword */: + case 151 /* TypeKeyword */: + case 153 /* UniqueKeyword */: + case 154 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 143 /* ReadonlyKeyword */; + return kind === 144 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { case 126 /* AbstractKeyword */: - case 133 /* ConstructorKeyword */: - case 135 /* GetKeyword */: - case 147 /* SetKeyword */: - case 130 /* AsyncKeyword */: - case 134 /* DeclareKeyword */: - case 157 /* OverrideKeyword */: + case 134 /* ConstructorKeyword */: + case 136 /* GetKeyword */: + case 148 /* SetKeyword */: + case 131 /* AsyncKeyword */: + case 135 /* DeclareKeyword */: + case 158 /* OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 130 /* AsyncKeyword */ - || kind === 131 /* AwaitKeyword */ + return kind === 131 /* AsyncKeyword */ + || kind === 132 /* AwaitKeyword */ || kind === 127 /* AsKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } @@ -128840,16 +131520,9 @@ var ts; var type = hasCompletionsType && !(completionsType.flags & 3 /* AnyOrUnknown */) ? checker.getUnionType([contextualType, completionsType]) : contextualType; - var properties = type.isUnion() - ? checker.getAllPossiblePropertiesOfTypes(type.types.filter(function (memberType) { - // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. - return !(memberType.flags & 131068 /* Primitive */ || - checker.isArrayLikeType(memberType) || - ts.typeHasCallOrConstructSignatures(memberType, checker) || - checker.isTypeInvalidDueToUnionDiscriminant(memberType, obj)); - })) - : type.getApparentProperties(); - return hasCompletionsType ? properties.filter(hasDeclarationOtherThanSelf) : properties; + var properties = getApparentProperties(type, obj, checker); + return type.isClass() && containsNonPublicProperties(properties) ? [] : + hasCompletionsType ? ts.filter(properties, hasDeclarationOtherThanSelf) : properties; // Filter out members whose only declaration is the object literal itself to avoid // self-fulfilling completions like: // @@ -128860,6 +131533,20 @@ var ts; } } Completions.getPropertiesForObjectExpression = getPropertiesForObjectExpression; + function getApparentProperties(type, node, checker) { + if (!type.isUnion()) + return type.getApparentProperties(); + return checker.getAllPossiblePropertiesOfTypes(ts.filter(type.types, function (memberType) { + return !(memberType.flags & 131068 /* Primitive */ + || checker.isArrayLikeType(memberType) + || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) + || ts.typeHasCallOrConstructSignatures(memberType, checker) + || memberType.isClass() && containsNonPublicProperties(memberType.getApparentProperties())); + })); + } + function containsNonPublicProperties(props) { + return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */); }); + } /** * Gets all properties on a type, but if that type is a union of several types, * excludes array-like types or callable/constructable types. @@ -128876,7 +131563,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 343 /* SyntaxList */: + case 346 /* 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); @@ -128898,7 +131585,7 @@ var ts; if (!contextToken) return undefined; // class C { blah; constructor/**/ } and so on - if (location.kind === 133 /* ConstructorKeyword */ + if (location.kind === 134 /* ConstructorKeyword */ // class C { blah \n constructor/**/ } || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { return ts.findAncestor(contextToken, ts.isClassLike); @@ -128941,7 +131628,7 @@ var ts; case 26 /* SemicolonToken */: case 27 /* CommaToken */: case 79 /* Identifier */: - if (parent.kind === 164 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + if (parent.kind === 165 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { return parent.parent; } break; @@ -128958,11 +131645,11 @@ var ts; if (!t) return undefined; switch (node.kind) { - case 164 /* PropertySignature */: + case 165 /* PropertySignature */: return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); - case 186 /* IntersectionType */: - case 180 /* TypeLiteral */: - case 185 /* UnionType */: + case 187 /* IntersectionType */: + case 181 /* TypeLiteral */: + case 186 /* UnionType */: return t; } } @@ -128990,7 +131677,7 @@ var ts; ? !!ts.tryGetImportFromModuleSpecifier(contextToken) : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); case " ": - return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 300 /* SourceFile */; + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 303 /* SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -129031,34 +131718,67 @@ var ts; } return undefined; } - function getImportCompletionNode(contextToken) { + function getImportStatementCompletionInfo(contextToken) { + var keywordCompletion; + var isKeywordOnlyCompletion = false; var candidate = getCandidate(); - return candidate === 154 /* FromKeyword */ || candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined; + return { + isKeywordOnlyCompletion: isKeywordOnlyCompletion, + keywordCompletion: keywordCompletion, + isNewIdentifierLocation: !!(candidate || keywordCompletion === 151 /* TypeKeyword */), + replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) + ? candidate + : undefined + }; function getCandidate() { var parent = contextToken.parent; if (ts.isImportEqualsDeclaration(parent)) { + keywordCompletion = contextToken.kind === 151 /* TypeKeyword */ ? undefined : 151 /* TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; } + if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) { + return parent; + } if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { - if (isModuleSpecifierMissingOrEmpty(parent.parent.parent.moduleSpecifier) && (ts.isNamespaceImport(parent) || parent.elements.length < 2) && !parent.parent.name) { + if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* OpenBraceToken */ || + contextToken.kind === 100 /* ImportKeyword */ || + contextToken.kind === 27 /* CommaToken */)) { + keywordCompletion = 151 /* TypeKeyword */; + } + if (canCompleteFromNamedBindings(parent)) { // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` - return contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */ - ? 154 /* FromKeyword */ - : parent.parent.parent; + if (contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */) { + isKeywordOnlyCompletion = true; + keywordCompletion = 155 /* FromKeyword */; + } + else { + return parent.parent.parent; + } } return undefined; } if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { // A lone import keyword with nothing following it does not parse as a statement at all + keywordCompletion = 151 /* TypeKeyword */; return contextToken; } if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { // `import s| from` + keywordCompletion = 151 /* TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; } return undefined; } } + function couldBeTypeOnlyImportSpecifier(importSpecifier, contextToken) { + return ts.isImportSpecifier(importSpecifier) + && (importSpecifier.isTypeOnly || contextToken === importSpecifier.name && ts.isTypeKeywordTokenOrIdentifier(contextToken)); + } + function canCompleteFromNamedBindings(namedBindings) { + return isModuleSpecifierMissingOrEmpty(namedBindings.parent.parent.moduleSpecifier) + && (ts.isNamespaceImport(namedBindings) || namedBindings.elements.length < 2) + && !namedBindings.parent.name; + } function isModuleSpecifierMissingOrEmpty(specifier) { var _a; if (ts.nodeIsMissing(specifier)) @@ -129221,14 +131941,14 @@ var ts; case 115 /* WhileKeyword */: case 90 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - 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 */: + case 134 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* ConstructorKeyword */]); + case 136 /* GetKeyword */: + case 148 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [136 /* GetKeyword */, 148 /* SetKeyword */]); + case 132 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 130 /* AsyncKeyword */: + case 131 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); case 125 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); @@ -129273,7 +131993,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 300 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 303 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -129305,16 +132025,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 247 /* SwitchStatement */: - if (statement.kind === 243 /* ContinueStatement */) { + case 248 /* SwitchStatement */: + if (statement.kind === 244 /* ContinueStatement */) { return false; } // falls through - case 240 /* ForStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: - case 239 /* WhileStatement */: - case 238 /* DoStatement */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 240 /* WhileStatement */: + case 239 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -129330,11 +132050,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 260 /* ModuleBlock */: - case 300 /* SourceFile */: - case 233 /* Block */: - case 287 /* CaseClause */: - case 288 /* DefaultClause */: + case 261 /* ModuleBlock */: + case 303 /* SourceFile */: + case 234 /* Block */: + case 288 /* CaseClause */: + case 289 /* 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, true), [declaration], false); @@ -129342,14 +132062,14 @@ var ts; else { return container.statements; } - case 169 /* Constructor */: - case 167 /* MethodDeclaration */: - case 254 /* FunctionDeclaration */: + case 170 /* Constructor */: + case 168 /* MethodDeclaration */: + case 255 /* 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 */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: + case 181 /* 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. @@ -129364,7 +132084,7 @@ var ts; } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -129385,7 +132105,7 @@ var ts; var keywords = []; 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 === 238 /* DoStatement */) { + if (loopNode.kind === 239 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { @@ -129405,13 +132125,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 240 /* ForStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: - case 238 /* DoStatement */: - case 239 /* WhileStatement */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -129484,13 +132204,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 130 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 131 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 131 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 132 /* AwaitKeyword */); } }); }); @@ -129645,7 +132365,7 @@ var ts; } function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { scriptKind = ts.ensureScriptKind(fileName, scriptKind); - var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target || 1 /* ES5 */; + var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings); var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); var bucketEntry = bucket.get(path); var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); @@ -129820,14 +132540,14 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 206 /* CallExpression */: + case 207 /* CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 252 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 253 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 79 /* Identifier */) { directImports.push(name); @@ -129838,25 +132558,25 @@ var ts; break; case 79 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 266 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 267 /* 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 270 /* ExportDeclaration */: + case 271 /* 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 === 272 /* NamespaceExport */) { + else if (direct.exportClause.kind === 273 /* NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -129865,7 +132585,7 @@ var ts; directImports.push(direct); } break; - case 198 /* ImportType */: + case 199 /* ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -129898,7 +132618,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 300 /* SourceFile */ || sourceFileLike.kind === 259 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 303 /* SourceFile */ || sourceFileLike.kind === 260 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -129954,7 +132674,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 263 /* ImportEqualsDeclaration */) { + if (decl.kind === 264 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -129964,7 +132684,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 198 /* ImportType */) { + if (decl.kind === 199 /* ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { @@ -129980,7 +132700,7 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 270 /* ExportDeclaration */) { + if (decl.kind === 271 /* ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -129989,10 +132709,10 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 266 /* NamespaceImport */: + case 267 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 267 /* NamedImports */: + case 268 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -130042,7 +132762,7 @@ var ts; } } else { - var localSymbol = element.kind === 273 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 274 /* 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); @@ -130071,7 +132791,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) === 300 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 303 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -130119,7 +132839,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 === 300 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 303 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -130134,15 +132854,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 270 /* ExportDeclaration */: - case 264 /* ImportDeclaration */: { + case 271 /* ExportDeclaration */: + case 265 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 263 /* ImportEqualsDeclaration */: { + case 264 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -130167,7 +132887,7 @@ var ts; var parent = node.parent; var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 204 /* PropertyAccessExpression */) { + if (parent.kind === 205 /* 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) @@ -130301,16 +133021,16 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 268 /* ImportSpecifier */: + case 269 /* 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 265 /* ImportClause */: - case 266 /* NamespaceImport */: + case 266 /* ImportClause */: + case 267 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 201 /* BindingElement */: + case 202 /* BindingElement */: return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); default: return false; @@ -130351,21 +133071,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 206 /* CallExpression */) { + if (node.kind === 207 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 300 /* SourceFile */) { + if (parent.kind === 303 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 260 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 261 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 259 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 260 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 275 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 276 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -130468,7 +133188,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -130476,28 +133196,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 201 /* BindingElement */: + case 202 /* BindingElement */: return getContextNode(node.parent.parent); - case 268 /* ImportSpecifier */: + case 269 /* ImportSpecifier */: return node.parent.parent.parent; - case 273 /* ExportSpecifier */: - case 266 /* NamespaceImport */: + case 274 /* ExportSpecifier */: + case 267 /* NamespaceImport */: return node.parent.parent; - case 265 /* ImportClause */: - case 272 /* NamespaceExport */: + case 266 /* ImportClause */: + case 273 /* NamespaceExport */: return node.parent; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 242 /* ForOfStatement */: - case 241 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 242 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 291 /* PropertyAssignment */: - case 292 /* ShorthandPropertyAssignment */: + case 294 /* PropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -130540,12 +133260,13 @@ var ts; var node = ts.getTouchingPropertyName(sourceFile, position); var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, { use: 1 /* References */ }); var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(node); return !referencedSymbols || !referencedSymbols.length ? undefined : ts.mapDefined(referencedSymbols, function (_a) { var definition = _a.definition, references = _a.references; // Only include referenced symbols that have a valid definition. return definition && { definition: checker.runWithCancellationToken(cancellationToken, function (checker) { return definitionToReferencedSymbolDefinitionInfo(definition, checker, node); }), - references: references.map(toReferenceEntry) + references: references.map(function (r) { return toReferenceEntry(r, symbol); }) }; }); } @@ -130554,9 +133275,9 @@ var ts; var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 204 /* PropertyAccessExpression */ - || node.parent.kind === 201 /* BindingElement */ - || node.parent.kind === 205 /* ElementAccessExpression */ + if (node.parent.kind === 205 /* PropertyAccessExpression */ + || node.parent.kind === 202 /* BindingElement */ + || node.parent.kind === 206 /* ElementAccessExpression */ || node.kind === 106 /* SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries, true); } @@ -130580,13 +133301,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 300 /* SourceFile */) { + if (node.kind === 303 /* 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 === 292 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 295 /* ShorthandPropertyAssignment */) { var result_2 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); }); return result_2; @@ -130678,13 +133399,13 @@ var ts; return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker))); } FindAllReferences.toRenameLocation = toRenameLocation; - function toReferenceEntry(entry) { + function toReferenceEntry(entry, symbol) { var documentSpan = entryToDocumentSpan(entry); if (entry.kind === 0 /* Span */) { return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: isDefinitionForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: isDeclarationOfSymbol(node, symbol), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } FindAllReferences.toReferenceEntry = toReferenceEntry; function entryToDocumentSpan(entry) { @@ -130756,13 +133477,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 203 /* ObjectLiteralExpression */) { + else if (node.kind === 204 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 224 /* ClassExpression */) { + else if (node.kind === 225 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -130808,11 +133529,18 @@ var ts; var decl = ts.getDeclarationFromName(node); return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); } - function isDefinitionForReference(node) { - return node.kind === 88 /* DefaultKeyword */ - || !!ts.getDeclarationFromName(node) - || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 133 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + /** Whether a reference, `node`, is a definition of the `target` symbol */ + function isDeclarationOfSymbol(node, target) { + var _a; + if (!target) + return false; + var source = ts.getDeclarationFromName(node) || + (node.kind === 88 /* DefaultKeyword */ ? node.parent + : ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent + : node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent + : undefined); + var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined; + return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; }))); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -130823,47 +133551,47 @@ var ts; if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 219 /* BinaryExpression */: - case 201 /* BindingElement */: - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 220 /* BinaryExpression */: + case 202 /* BindingElement */: + case 256 /* ClassDeclaration */: + case 225 /* 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 */: + case 259 /* EnumDeclaration */: + case 297 /* EnumMember */: + case 274 /* ExportSpecifier */: + case 266 /* ImportClause */: // default import + case 264 /* ImportEqualsDeclaration */: + case 269 /* ImportSpecifier */: + case 257 /* InterfaceDeclaration */: + case 336 /* JSDocCallbackTag */: + case 343 /* JSDocTypedefTag */: + case 284 /* JsxAttribute */: + case 260 /* ModuleDeclaration */: + case 263 /* NamespaceExportDeclaration */: + case 267 /* NamespaceImport */: + case 273 /* NamespaceExport */: + case 163 /* Parameter */: + case 295 /* ShorthandPropertyAssignment */: + case 258 /* TypeAliasDeclaration */: + case 162 /* TypeParameter */: return true; - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 169 /* Constructor */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 170 /* Constructor */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return !!decl.body; - case 252 /* VariableDeclaration */: - case 165 /* PropertyDeclaration */: + case 253 /* VariableDeclaration */: + case 166 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 166 /* MethodSignature */: - case 164 /* PropertySignature */: - case 342 /* JSDocPropertyTag */: - case 335 /* JSDocParameterTag */: + case 167 /* MethodSignature */: + case 165 /* PropertySignature */: + case 345 /* JSDocPropertyTag */: + case 338 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -130916,7 +133644,7 @@ var ts; if (!options.implementations && ts.isStringLiteralLike(node)) { if (ts.isModuleSpecifierLike(node)) { var fileIncludeReasons = program.getFileIncludeReasons(); - var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName; + var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; @@ -131015,7 +133743,7 @@ var ts; result = references; continue; } - var _loop_4 = function (entry) { + var _loop_5 = function (entry) { if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { result.push(entry); return "continue"; @@ -131047,7 +133775,7 @@ var ts; }; for (var _b = 0, references_2 = references; _b < references_2.length; _b++) { var entry = references_2[_b]; - _loop_4(entry); + _loop_5(entry); } } return result; @@ -131084,10 +133812,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 300 /* SourceFile */: + case 303 /* 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 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } @@ -131116,9 +133844,9 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 143 /* ReadonlyKeyword */ + return node.kind === 144 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 143 /* ReadonlyKeyword */; + && node.parent.operator === 144 /* ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { @@ -131129,12 +133857,12 @@ var ts; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 143 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 144 /* 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 === 143 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 144 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }]; @@ -131198,8 +133926,8 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 169 /* Constructor */: - case 133 /* ConstructorKeyword */: + case 170 /* Constructor */: + case 134 /* ConstructorKeyword */: return 1 /* Constructor */; case 79 /* Identifier */: if (ts.isClassLike(node.parent)) { @@ -131418,7 +134146,7 @@ var ts; getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* Import */), state, state.includesSourceFile(exportingFile)); } } - /** Search for all occurences of an identifier in a source file (and filter out the ones that match). */ + /** Search for all occurrences of an identifier in a source file (and filter out the ones that match). */ function searchForName(sourceFile, search, state) { if (ts.getNameTable(sourceFile).get(search.escapedText) !== undefined) { getReferencesInSourceFile(sourceFile, search, state); @@ -131441,7 +134169,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 === 211 /* FunctionExpression */ || valueDeclaration.kind === 224 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 212 /* FunctionExpression */ || valueDeclaration.kind === 225 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -131451,7 +134179,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, 255 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 256 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -131480,7 +134208,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 300 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 303 /* 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; @@ -131701,9 +134429,15 @@ 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 === 201 /* BindingElement */ && ts.isRequireVariableDeclaration(referenceLocation.parent) - ? referenceLocation.parent.symbol - : referenceSymbol; + if (ts.isInJSFile(referenceLocation) + && referenceLocation.parent.kind === 202 /* BindingElement */ + && ts.isRequireVariableDeclaration(referenceLocation.parent)) { + referenceSymbol = referenceLocation.parent.symbol; + // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In + // this case, just skip it, since the bound identifiers are not an alias of the import. + if (!referenceSymbol) + return; + } getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); } function getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, search, state, addReferencesHere, alwaysGetReferences) { @@ -131865,15 +134599,15 @@ 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, 133 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 169 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 134 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 170 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 167 /* MethodDeclaration */) { + if (decl && decl.kind === 168 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { @@ -131897,7 +134631,7 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 169 /* Constructor */); + ts.Debug.assert(decl.kind === 170 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { @@ -131927,7 +134661,7 @@ var ts; if (refNode.kind !== 79 /* Identifier */) { return; } - if (refNode.parent.kind === 292 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 295 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -131947,7 +134681,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 233 /* Block */) { + if (body.kind === 234 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -131975,13 +134709,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 210 /* ParenthesizedExpression */: + case 211 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 212 /* ArrowFunction */: - case 211 /* FunctionExpression */: - case 203 /* ObjectLiteralExpression */: - case 224 /* ClassExpression */: - case 202 /* ArrayLiteralExpression */: + case 213 /* ArrowFunction */: + case 212 /* FunctionExpression */: + case 204 /* ObjectLiteralExpression */: + case 225 /* ClassExpression */: + case 203 /* ArrayLiteralExpression */: return true; default: return false; @@ -132034,13 +134768,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: - case 169 /* Constructor */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -132061,43 +134795,43 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 79 /* Identifier */ && node.parent.kind === 162 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* Identifier */ && node.parent.kind === 163 /* 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 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: - case 169 /* Constructor */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 300 /* SourceFile */: + case 303 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 212 /* 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 === 300 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 303 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -132105,20 +134839,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 211 /* FunctionExpression */: - case 254 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 224 /* ClassExpression */: - case 255 /* ClassDeclaration */: - case 203 /* ObjectLiteralExpression */: + case 225 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 204 /* 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.isStatic(container) === !!staticFlag; - case 300 /* SourceFile */: - return container.kind === 300 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 303 /* SourceFile */: + return container.kind === 303 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); @@ -132129,13 +134863,13 @@ var ts; }]; } function getReferencesForStringLiteral(node, sourceFiles, checker, cancellationToken) { - var type = ts.getContextualTypeOrAncestorTypeNodeType(node, checker); + var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, checker); var references = ts.flatMap(sourceFiles, function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, node.text), function (ref) { if (ts.isStringLiteralLike(ref) && ref.text === node.text) { if (type) { - var refType = ts.getContextualTypeOrAncestorTypeNodeType(ref, checker); + var refType = ts.getContextualTypeFromParentOrAncestorTypeNode(ref, checker); if (type !== checker.getStringType() && type === refType) { return nodeEntry(ref, 2 /* StringLiteral */); } @@ -132228,7 +134962,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, 273 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 274 /* ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { @@ -132273,7 +135007,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 201 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 202 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -132306,9 +135040,8 @@ var ts; } } function isStaticSymbol(symbol) { - if (!symbol.valueDeclaration) { + if (!symbol.valueDeclaration) return false; - } var modifierFlags = ts.getEffectiveModifierFlags(symbol.valueDeclaration); return !!(modifierFlags & 32 /* Static */); } @@ -132537,16 +135270,16 @@ var ts; return; } switch (node.kind) { - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 167 /* MethodDeclaration */: - if (node.parent.kind === 203 /* ObjectLiteralExpression */) { + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 168 /* MethodDeclaration */: + if (node.parent.kind === 204 /* 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 254 /* FunctionDeclaration */: - case 255 /* ClassDeclaration */: - case 259 /* ModuleDeclaration */: + case 255 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: + case 260 /* ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -132761,58 +135494,58 @@ var ts; } switch (node.kind) { case 79 /* Identifier */: - case 263 /* ImportEqualsDeclaration */: - case 264 /* ImportDeclaration */: - case 270 /* ExportDeclaration */: - case 256 /* InterfaceDeclaration */: - case 257 /* TypeAliasDeclaration */: + case 264 /* ImportEqualsDeclaration */: + case 265 /* ImportDeclaration */: + case 271 /* ExportDeclaration */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 168 /* ClassStaticBlockDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: recordCallSite(node); return; - case 209 /* TypeAssertionExpression */: - case 227 /* AsExpression */: + case 210 /* TypeAssertionExpression */: + case 228 /* AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 252 /* VariableDeclaration */: - case 162 /* Parameter */: + case 253 /* VariableDeclaration */: + case 163 /* Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 206 /* CallExpression */: + case 207 /* CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 207 /* NewExpression */: + case 208 /* NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 208 /* TaggedTemplateExpression */: + case 209 /* TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 278 /* JsxOpeningElement */: - case 277 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: + case 278 /* JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 163 /* Decorator */: + case 164 /* Decorator */: recordCallSite(node); collect(node.expression); return; - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -132868,25 +135601,25 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 300 /* SourceFile */: + case 303 /* SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; - case 168 /* ClassStaticBlockDeclaration */: + case 169 /* ClassStaticBlockDeclaration */: collectCallSitesOfClassStaticBlockDeclaration(node, collect); break; default: @@ -133020,7 +135753,7 @@ var ts; } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) { var allFiles = program.getSourceFiles(); - var _loop_5 = function (sourceFile) { + var _loop_6 = function (sourceFile) { var newFromOld = oldToNew(sourceFile.fileName); var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); @@ -133052,7 +135785,7 @@ var ts; }; for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { var sourceFile = allFiles_1[_i]; - _loop_5(sourceFile); + _loop_6(sourceFile); } } function combineNormal(pathA, pathB) { @@ -133069,9 +135802,10 @@ var ts; return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName: newFileName, updated: true }; } else { + var mode = ts.getModeForUsageLocation(importingSourceFile, importLiteral); var resolved = host.resolveModuleNames - ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName) - : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName); + ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode) + : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode); return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles()); } } @@ -133154,7 +135888,7 @@ var ts; } var parent = node.parent; var typeChecker = program.getTypeChecker(); - if (node.kind === 157 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { + if (node.kind === 158 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray; } // Labels @@ -133200,7 +135934,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 === 292 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 295 /* 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); @@ -133296,10 +136030,10 @@ var ts; var file = program.getLibFileFromReference(libReferenceDirective); return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false }; } - if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size) { + if ((_a = sourceFile.resolvedModules) === null || _a === void 0 ? void 0 : _a.size()) { var node = ts.getTokenAtPosition(sourceFile, position); - if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text)) { - var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text)) === null || _b === void 0 ? void 0 : _b.resolvedFileName; + if (ts.isModuleSpecifierLike(node) && ts.isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, ts.getModeForUsageLocation(sourceFile, node))) { + var verifiedFileName = (_b = sourceFile.resolvedModules.get(node.text, ts.getModeForUsageLocation(sourceFile, node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text); return { file: program.getSourceFile(fileName), @@ -133397,13 +136131,13 @@ var ts; return true; } switch (declaration.kind) { - case 265 /* ImportClause */: - case 263 /* ImportEqualsDeclaration */: + case 266 /* ImportClause */: + case 264 /* ImportEqualsDeclaration */: return true; - case 268 /* ImportSpecifier */: - return declaration.parent.kind === 267 /* NamedImports */; - case 201 /* BindingElement */: - case 252 /* VariableDeclaration */: + case 269 /* ImportSpecifier */: + return declaration.parent.kind === 268 /* NamedImports */; + case 202 /* BindingElement */: + case 253 /* VariableDeclaration */: return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); default: return false; @@ -133419,7 +136153,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 === 133 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* 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); } @@ -133470,22 +136204,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 165 /* PropertyDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 167 /* MethodDeclaration */: + case 166 /* PropertyDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 168 /* 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 169 /* Constructor */: - case 291 /* PropertyAssignment */: - case 292 /* ShorthandPropertyAssignment */: - case 203 /* ObjectLiteralExpression */: - case 224 /* ClassExpression */: - case 212 /* ArrowFunction */: - case 211 /* FunctionExpression */: + case 170 /* Constructor */: + case 294 /* PropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: + case 204 /* ObjectLiteralExpression */: + case 225 /* ClassExpression */: + case 213 /* ArrowFunction */: + case 212 /* FunctionExpression */: return isDefinitionVisible(checker, declaration.parent); default: return false; @@ -133523,9 +136257,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 169 /* Constructor */: - case 178 /* ConstructorType */: - case 173 /* ConstructSignature */: + case 170 /* Constructor */: + case 179 /* ConstructorType */: + case 174 /* ConstructSignature */: return true; default: return false; @@ -133637,10 +136371,10 @@ var ts; // - @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 */ + && declaration.kind !== 343 /* JSDocTypedefTag */ && declaration.kind !== 336 /* 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 */; })) { + && jsdoc.tags.some(function (t) { return t.kind === 343 /* JSDocTypedefTag */ || t.kind === 336 /* JSDocCallbackTag */; }) + && !jsdoc.tags.some(function (t) { return t.kind === 338 /* JSDocParameterTag */ || t.kind === 339 /* JSDocReturnTag */; })) { continue; } var newparts = getDisplayPartsFromComment(jsdoc.comment, checker); @@ -133657,11 +136391,11 @@ var ts; } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 335 /* JSDocParameterTag */: - case 342 /* JSDocPropertyTag */: + case 338 /* JSDocParameterTag */: + case 345 /* JSDocPropertyTag */: return [declaration]; - case 333 /* JSDocCallbackTag */: - case 340 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: + case 343 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -133675,8 +136409,8 @@ var ts; // 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 */; })) { + if (tags.some(function (t) { return t.kind === 343 /* JSDocTypedefTag */ || t.kind === 336 /* JSDocCallbackTag */; }) + && !tags.some(function (t) { return t.kind === 338 /* JSDocParameterTag */ || t.kind === 339 /* JSDocReturnTag */; })) { return; } for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { @@ -133691,25 +136425,25 @@ var ts; if (typeof comment === "string") { return [ts.textPart(comment)]; } - return ts.flatMap(comment, function (node) { return node.kind === 316 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + return ts.flatMap(comment, function (node) { return node.kind === 319 /* 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 324 /* JSDocImplementsTag */: + case 327 /* JSDocImplementsTag */: return withNode(tag.class); - case 323 /* JSDocAugmentsTag */: + case 326 /* JSDocAugmentsTag */: return withNode(tag.class); - case 339 /* JSDocTemplateTag */: + case 342 /* JSDocTemplateTag */: return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", ")); - case 338 /* JSDocTypeTag */: + case 341 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 340 /* JSDocTypedefTag */: - case 333 /* JSDocCallbackTag */: - case 342 /* JSDocPropertyTag */: - case 335 /* JSDocParameterTag */: - case 341 /* JSDocSeeTag */: + case 343 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: + case 345 /* JSDocPropertyTag */: + case 338 /* JSDocParameterTag */: + case 344 /* JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment === undefined ? undefined @@ -133736,14 +136470,14 @@ var ts; } function getTagNameDisplayPart(kind) { switch (kind) { - case 335 /* JSDocParameterTag */: + case 338 /* JSDocParameterTag */: return ts.parameterNamePart; - case 342 /* JSDocPropertyTag */: + case 345 /* JSDocPropertyTag */: return ts.propertyNamePart; - case 339 /* JSDocTemplateTag */: + case 342 /* JSDocTemplateTag */: return ts.typeParameterNamePart; - case 340 /* JSDocTypedefTag */: - case 333 /* JSDocCallbackTag */: + case 343 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: return ts.typeAliasNamePart; default: return ts.textPart; @@ -133907,24 +136641,24 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 167 /* MethodDeclaration */: - case 169 /* Constructor */: - case 166 /* MethodSignature */: - case 212 /* ArrowFunction */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 168 /* MethodDeclaration */: + case 170 /* Constructor */: + case 167 /* MethodSignature */: + case 213 /* ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: - case 164 /* PropertySignature */: - case 258 /* EnumDeclaration */: - case 294 /* EnumMember */: - case 257 /* TypeAliasDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 165 /* PropertySignature */: + case 259 /* EnumDeclaration */: + case 297 /* EnumMember */: + case 258 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 235 /* VariableStatement */: { + case 236 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -133934,16 +136668,16 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 300 /* SourceFile */: + case 303 /* SourceFile */: return "quit"; - case 259 /* ModuleDeclaration */: + case 260 /* 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 === 259 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 236 /* ExpressionStatement */: + return commentOwner.parent.kind === 260 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 237 /* ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 219 /* BinaryExpression */: { + case 220 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -133952,7 +136686,7 @@ var ts; ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -133965,14 +136699,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 === 210 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 211 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return rightHandSide; - case 224 /* ClassExpression */: + case 225 /* ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -133988,7 +136722,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_6 = function (sourceFile) { + var _loop_7 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && sourceFile.isDeclarationFile) { return "continue"; @@ -134000,7 +136734,7 @@ var ts; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var sourceFile = sourceFiles_4[_i]; - _loop_6(sourceFile); + _loop_7(sourceFile); } rawItems.sort(compareNavigateToItems); return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); @@ -134031,9 +136765,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 265 /* ImportClause */: - case 268 /* ImportSpecifier */: - case 263 /* ImportEqualsDeclaration */: + case 266 /* ImportClause */: + case 269 /* ImportSpecifier */: + case 264 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -134043,7 +136777,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 160 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 161 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -134060,7 +136794,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 === 160 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 161 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -134277,7 +137011,7 @@ var ts; */ function hasNavigationBarName(node) { return !ts.hasDynamicName(node) || - (node.kind !== 219 /* BinaryExpression */ && + (node.kind !== 220 /* BinaryExpression */ && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && ts.idText(node.name.expression.expression) === "Symbol"); @@ -134290,7 +137024,7 @@ var ts; return; } switch (node.kind) { - case 169 /* Constructor */: + case 170 /* 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); @@ -134302,25 +137036,25 @@ var ts; } } break; - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 166 /* MethodSignature */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 167 /* MethodSignature */: if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 164 /* PropertySignature */: + case 165 /* PropertySignature */: if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 265 /* ImportClause */: + case 266 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -134332,7 +137066,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 266 /* NamespaceImport */) { + if (namedBindings.kind === 267 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -134343,17 +137077,17 @@ var ts; } } break; - case 292 /* ShorthandPropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 293 /* SpreadAssignment */: + case 296 /* 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 201 /* BindingElement */: - case 291 /* PropertyAssignment */: - case 252 /* VariableDeclaration */: { + case 202 /* BindingElement */: + case 294 /* PropertyAssignment */: + case 253 /* VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -134363,7 +137097,7 @@ var ts; } break; } - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -134371,11 +137105,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 212 /* ArrowFunction */: - case 211 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 212 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -134385,9 +137119,9 @@ var ts; } endNode(); break; - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: - case 256 /* InterfaceDeclaration */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -134395,10 +137129,10 @@ var ts; } endNode(); break; - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 269 /* ExportAssignment */: { + case 270 /* 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; @@ -134412,16 +137146,16 @@ var ts; } break; } - case 273 /* ExportSpecifier */: - case 263 /* ImportEqualsDeclaration */: - case 174 /* IndexSignature */: - case 172 /* CallSignature */: - case 173 /* ConstructSignature */: - case 257 /* TypeAliasDeclaration */: + case 274 /* ExportSpecifier */: + case 264 /* ImportEqualsDeclaration */: + case 175 /* IndexSignature */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 258 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 206 /* CallExpression */: - case 219 /* BinaryExpression */: { + case 207 /* CallExpression */: + case 220 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -134663,12 +137397,12 @@ var ts; return false; } switch (a.kind) { - case 165 /* PropertyDeclaration */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 166 /* PropertyDeclaration */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return ts.isStatic(a) === ts.isStatic(b); - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return areSameModule(a, b) && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: @@ -134687,7 +137421,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 !== 259 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -134717,7 +137451,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 259 /* ModuleDeclaration */) { + if (node.kind === 260 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -134726,16 +137460,16 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: - case 224 /* ClassExpression */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 225 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 259 /* ModuleDeclaration */) { + if (node.kind === 260 /* ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { @@ -134747,18 +137481,18 @@ var ts; } } switch (node.kind) { - case 300 /* SourceFile */: + case 303 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 212 /* ArrowFunction */: - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: + case 213 /* ArrowFunction */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -134766,13 +137500,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 169 /* Constructor */: + case 170 /* Constructor */: return "constructor"; - case 173 /* ConstructSignature */: + case 174 /* ConstructSignature */: return "new()"; - case 172 /* CallSignature */: + case 173 /* CallSignature */: return "()"; - case 174 /* IndexSignature */: + case 175 /* IndexSignature */: return "[]"; default: return ""; @@ -134805,19 +137539,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - 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 */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 259 /* EnumDeclaration */: + case 257 /* InterfaceDeclaration */: + case 260 /* ModuleDeclaration */: + case 303 /* SourceFile */: + case 258 /* TypeAliasDeclaration */: + case 343 /* JSDocTypedefTag */: + case 336 /* JSDocCallbackTag */: return true; - case 212 /* ArrowFunction */: - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -134827,10 +137561,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 260 /* ModuleBlock */: - case 300 /* SourceFile */: - case 167 /* MethodDeclaration */: - case 169 /* Constructor */: + case 261 /* ModuleBlock */: + case 303 /* SourceFile */: + case 168 /* MethodDeclaration */: + case 170 /* Constructor */: return true; default: return false; @@ -134892,7 +137626,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 === 259 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 260 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -134906,13 +137640,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 160 /* ComputedPropertyName */; + return !member.name || member.name.kind === 161 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 300 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 303 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 252 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 253 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -134970,9 +137704,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 212 /* ArrowFunction */: - case 211 /* FunctionExpression */: - case 224 /* ClassExpression */: + case 213 /* ArrowFunction */: + case 212 /* FunctionExpression */: + case 225 /* ClassExpression */: return true; default: return false; @@ -135012,9 +137746,8 @@ var ts; organizeImportsWorker(topLevelExportDecls, coalesceExports); for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) { var ambientModule = _a[_i]; - if (!ambientModule.body) { + if (!ambientModule.body) continue; - } var ambientModuleImportDecls = ambientModule.body.statements.filter(ts.isImportDeclaration); organizeImportsWorker(ambientModuleImportDecls, coalesceAndOrganizeImports); var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration); @@ -135110,7 +137843,8 @@ var ts; // If we’re in a declaration file, it’s safe to remove the import clause from it if (sourceFile.isDeclarationFile) { usedImports.push(ts.factory.createImportDeclaration(importDecl.decorators, importDecl.modifiers, - /*importClause*/ undefined, moduleSpecifier)); + /*importClause*/ undefined, moduleSpecifier, + /*assertClause*/ undefined)); } // If we’re not in a declaration file, we can’t remove the import clause even though // the imported symbols are unused, because removing them makes it look like the import @@ -135184,7 +137918,7 @@ var ts; else { for (var _e = 0, defaultImports_1 = defaultImports; _e < defaultImports_1.length; _e++) { var defaultImport = defaultImports_1[_e]; - newImportSpecifiers.push(ts.factory.createImportSpecifier(ts.factory.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217 + newImportSpecifiers.push(ts.factory.createImportSpecifier(/*isTypeOnly*/ false, ts.factory.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217 } } newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217 @@ -135276,7 +138010,7 @@ var ts; var exportDecl = exportGroup_1[0]; coalescedExports.push(ts.factory.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.isTypeOnly, exportDecl.exportClause && (ts.isNamedExports(exportDecl.exportClause) ? ts.factory.updateNamedExports(exportDecl.exportClause, sortedExportSpecifiers) : - ts.factory.updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)), exportDecl.moduleSpecifier)); + ts.factory.updateNamespaceExport(exportDecl.exportClause, exportDecl.exportClause.name)), exportDecl.moduleSpecifier, exportDecl.assertClause)); } return coalescedExports; /* @@ -135312,13 +138046,14 @@ var ts; OrganizeImports.coalesceExports = coalesceExports; function updateImportDeclarationAndClause(importDeclaration, name, namedBindings) { return ts.factory.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.factory.updateImportClause(importDeclaration.importClause, importDeclaration.importClause.isTypeOnly, name, namedBindings), // TODO: GH#18217 - importDeclaration.moduleSpecifier); + importDeclaration.moduleSpecifier, importDeclaration.assertClause); } function sortSpecifiers(specifiers) { return ts.stableSort(specifiers, compareImportOrExportSpecifiers); } function compareImportOrExportSpecifiers(s1, s2) { - return compareIdentifiers(s1.propertyName || s1.name, s2.propertyName || s2.name) + return ts.compareBooleans(s1.isTypeOnly, s2.isTypeOnly) + || compareIdentifiers(s1.propertyName || s1.name, s2.propertyName || s2.name) || compareIdentifiers(s1.name, s2.name); } OrganizeImports.compareImportOrExportSpecifiers = compareImportOrExportSpecifiers; @@ -135337,11 +138072,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return declaration.moduleSpecifier; - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -135380,19 +138115,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 264 /* ImportDeclaration */: + case 265 /* 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) === 266 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 267 /* NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return 5; - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return 6; } } @@ -135566,7 +138301,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 233 /* Block */: + case 234 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -135574,16 +138309,16 @@ 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 238 /* DoStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: - case 240 /* ForStatement */: - case 237 /* IfStatement */: - case 239 /* WhileStatement */: - case 246 /* WithStatement */: - case 290 /* CatchClause */: + case 239 /* DoStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 241 /* ForStatement */: + case 238 /* IfStatement */: + case 240 /* WhileStatement */: + case 247 /* WithStatement */: + case 291 /* CatchClause */: return spanForNode(n.parent); - case 250 /* TryStatement */: + case 251 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -135600,40 +138335,40 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 260 /* ModuleBlock */: + case 261 /* ModuleBlock */: return spanForNode(n.parent); - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: - case 256 /* InterfaceDeclaration */: - case 258 /* EnumDeclaration */: - case 261 /* CaseBlock */: - case 180 /* TypeLiteral */: - case 199 /* ObjectBindingPattern */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: + case 259 /* EnumDeclaration */: + case 262 /* CaseBlock */: + case 181 /* TypeLiteral */: + case 200 /* ObjectBindingPattern */: return spanForNode(n); - case 182 /* TupleType */: + case 183 /* TupleType */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 287 /* CaseClause */: - case 288 /* DefaultClause */: + case 288 /* CaseClause */: + case 289 /* DefaultClause */: return spanForNodeArray(n.statements); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 276 /* JsxElement */: + case 277 /* JsxElement */: return spanForJSXElement(n); - case 280 /* JsxFragment */: + case 281 /* JsxFragment */: return spanForJSXFragment(n); - case 277 /* JsxSelfClosingElement */: - case 278 /* JsxOpeningElement */: + case 278 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 221 /* TemplateExpression */: + case 222 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 200 /* ArrayBindingPattern */: + case 201 /* ArrayBindingPattern */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return spanForArrowFunction(n); - case 206 /* CallExpression */: + case 207 /* CallExpression */: return spanForCallExpression(n); } function spanForCallExpression(node) { @@ -135700,7 +138435,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 !== 212 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 213 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -136003,15 +138738,15 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_7 = function (start) { + var _loop_8 = function (start) { if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) { return { value: start }; } }; for (var start = 0; start <= n; start++) { - var state_2 = _loop_7(start); - if (typeof state_2 === "object") - return state_2.value; + var state_3 = _loop_8(start); + if (typeof state_3 === "object") + return state_3.value; } return -1; } @@ -136244,10 +138979,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 134 /* DeclareKeyword */) { + if (token === 135 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 140 /* ModuleKeyword */) { + if (token === 141 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -136281,10 +139016,10 @@ var ts; return true; } else { - if (token === 150 /* TypeKeyword */) { + if (token === 151 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 154 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || + return token !== 155 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || token === 18 /* OpenBraceToken */ || token === 79 /* Identifier */ || ts.isKeyword(token)); @@ -136295,7 +139030,7 @@ var ts; } if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 154 /* FromKeyword */) { + if (token === 155 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -136326,7 +139061,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 154 /* FromKeyword */) { + if (token === 155 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -136342,7 +139077,7 @@ var ts; token = nextToken(); if (token === 79 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 154 /* FromKeyword */) { + if (token === 155 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -136363,7 +139098,7 @@ var ts; if (token === 93 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 150 /* TypeKeyword */) { + if (token === 151 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); return token === 41 /* AsteriskToken */ || @@ -136382,7 +139117,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 154 /* FromKeyword */) { + if (token === 155 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -136394,7 +139129,7 @@ var ts; } else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 154 /* FromKeyword */) { + if (token === 155 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -136404,7 +139139,7 @@ var ts; } else if (token === 100 /* ImportKeyword */) { token = nextToken(); - if (token === 150 /* TypeKeyword */) { + if (token === 151 /* TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); return token === 79 /* Identifier */ || @@ -136430,7 +139165,7 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 144 /* RequireKeyword */) { + if (token === 145 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -136575,7 +139310,7 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { if (ts.isStringLiteralLike(node)) { - var type = ts.getContextualTypeOrAncestorTypeNodeType(node, typeChecker); + var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker); if (type && ((type.flags & 128 /* StringLiteral */) || ((type.flags & 1048576 /* Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* StringLiteral */); })))) { return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile); } @@ -136602,7 +139337,7 @@ var ts; 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 === 160 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 161 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -136674,6 +139409,7 @@ var ts; return false; } } + Rename.nodeIsEligibleForRename = nodeIsEligibleForRename; })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); /* @internal */ @@ -136828,14 +139564,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 === 143 /* ReadonlyKeyword */ || + return child === node.readonlyToken || child.kind === 144 /* 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 === 161 /* TypeParameter */ || + kind === 162 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -136949,22 +139685,22 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 278 /* JsxOpeningElement */; + || kind === 279 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 279 /* JsxClosingElement */; + || kind === 280 /* JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 335 /* JSDocParameterTag */: - case 333 /* JSDocCallbackTag */: - case 342 /* JSDocPropertyTag */: - case 340 /* JSDocTypedefTag */: - case 337 /* JSDocThisTag */: + case 338 /* JSDocParameterTag */: + case 336 /* JSDocCallbackTag */: + case 345 /* JSDocPropertyTag */: + case 343 /* JSDocTypedefTag */: + case 340 /* JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -137174,10 +139910,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 208 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 209 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 221 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 222 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -137246,17 +139982,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 210 /* ParenthesizedExpression */: - case 167 /* MethodDeclaration */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 211 /* ParenthesizedExpression */: + case 168 /* MethodDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* 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 219 /* BinaryExpression */: { + case 220 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -137380,7 +140116,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 === 221 /* TemplateExpression */) { + if (template.kind === 222 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -137389,7 +140125,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) { - var _loop_8 = function (n) { + var _loop_9 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); }); @@ -137399,9 +140135,9 @@ var ts; } }; for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) { - var state_3 = _loop_8(n); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_9(n); + if (typeof state_4 === "object") + return state_4.value; } return undefined; } @@ -137585,14 +140321,14 @@ var ts; 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 */: + case 260 /* ModuleDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 255 /* FunctionDeclaration */: + case 225 /* ClassExpression */: + case 212 /* FunctionExpression */: + case 168 /* MethodDeclaration */: + case 213 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { @@ -137732,13 +140468,15 @@ var ts; } function isHintableLiteral(node) { switch (node.kind) { - case 217 /* PrefixUnaryExpression */: { + case 218 /* 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 */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 222 /* TemplateExpression */: return true; case 79 /* Identifier */: { var name = node.escapedText; @@ -137793,7 +140531,7 @@ var ts; if (!typeDisplayString) { continue; } - addTypeHints(typeDisplayString, param.end); + addTypeHints(typeDisplayString, param.name.end); } } function getParameterDeclarationTypeDisplayString(symbol) { @@ -137991,10 +140729,12 @@ var ts; program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; var checker = program.getTypeChecker(); - if (sourceFile.commonJsModuleIndicator && - (ts.programContainsEs6Modules(program) || ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) && + var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]); + if (!isCommonJSFile && + sourceFile.commonJsModuleIndicator && + (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) && containsTopLevelCommonjs(sourceFile)) { - diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module)); + diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module)); } var isJsFile = ts.isSourceFileJS(sourceFile); visitedNestedConvertibleFunctions.clear(); @@ -138006,7 +140746,7 @@ var ts; var name = importNameForConvertToDefaultImport(importNode); if (!name) continue; - var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text); + var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, moduleSpecifier)); var resolvedFile = module_1 && program.getSourceFile(module_1.resolvedFileName); if (resolvedFile && resolvedFile.externalModuleIndicator && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) { diags.push(ts.createDiagnosticForNode(name, ts.Diagnostics.Import_may_be_converted_to_a_default_import)); @@ -138043,15 +140783,15 @@ var ts; } } ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics; - // convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes. + // convertToEsModule only works on top-level, so don't trigger it if commonjs code only appears in nested scopes. function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 236 /* ExpressionStatement */: { + case 237 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -138068,12 +140808,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 266 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 267 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -138111,51 +140851,58 @@ var ts; // Should be kept up to date with transformExpression in convertToAsyncFunction.ts function isFixablePromiseHandler(node, checker) { // ensure outermost call exists and is a promise handler - if (!isPromiseHandler(node) || !node.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { + if (!isPromiseHandler(node) || !hasSupportedNumberOfArguments(node) || !node.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { return false; } // ensure all chained calls are valid - var currentNode = node.expression; + var currentNode = node.expression.expression; while (isPromiseHandler(currentNode) || ts.isPropertyAccessExpression(currentNode)) { - if (ts.isCallExpression(currentNode) && !currentNode.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { - return false; + if (ts.isCallExpression(currentNode)) { + if (!hasSupportedNumberOfArguments(currentNode) || !currentNode.arguments.every(function (arg) { return isFixablePromiseArgument(arg, checker); })) { + return false; + } + currentNode = currentNode.expression.expression; + } + else { + currentNode = currentNode.expression; } - currentNode = currentNode.expression; } return true; } ts.isFixablePromiseHandler = isFixablePromiseHandler; function isPromiseHandler(node) { - return ts.isCallExpression(node) && (ts.hasPropertyAccessExpressionWithName(node, "then") && hasSupportedNumberOfArguments(node) || - ts.hasPropertyAccessExpressionWithName(node, "catch")); + return ts.isCallExpression(node) && (ts.hasPropertyAccessExpressionWithName(node, "then") || + ts.hasPropertyAccessExpressionWithName(node, "catch") || + ts.hasPropertyAccessExpressionWithName(node, "finally")); } function hasSupportedNumberOfArguments(node) { - if (node.arguments.length > 2) + var name = node.expression.name.text; + var maxArguments = name === "then" ? 2 : name === "catch" ? 1 : name === "finally" ? 1 : 0; + if (node.arguments.length > maxArguments) return false; - if (node.arguments.length < 2) + if (node.arguments.length < maxArguments) return true; - return ts.some(node.arguments, function (arg) { - return arg.kind === 104 /* NullKeyword */ || - ts.isIdentifier(arg) && arg.text === "undefined"; + return maxArguments === 1 || ts.some(node.arguments, function (arg) { + 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 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: var functionFlags = ts.getFunctionFlags(arg); if (functionFlags & 1 /* Generator */) { return false; } // falls through - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through case 104 /* NullKeyword */: return true; case 79 /* Identifier */: - case 204 /* PropertyAccessExpression */: { + case 205 /* PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -138172,24 +140919,24 @@ var ts; } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 211 /* FunctionExpression */) { + if (node.kind === 212 /* 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 === 254 /* FunctionDeclaration */) { + if (node.kind === 255 /* FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } function canBeConvertedToAsync(node) { switch (node.kind) { - case 254 /* FunctionDeclaration */: - case 167 /* MethodDeclaration */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 255 /* FunctionDeclaration */: + case 168 /* MethodDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return true; default: return false; @@ -138211,7 +140958,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 224 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 225 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -138295,11 +141042,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 278 /* JsxOpeningElement */: - case 276 /* JsxElement */: - case 277 /* JsxSelfClosingElement */: + case 279 /* JsxOpeningElement */: + case 277 /* JsxElement */: + case 278 /* JsxSelfClosingElement */: return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 283 /* JsxAttribute */: + case 284 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -138367,7 +141114,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (location.parent && location.parent.kind === 204 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 205 /* 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)) { @@ -138387,7 +141134,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 207 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 208 /* 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 @@ -138451,29 +141198,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 133 /* ConstructorKeyword */ && location.parent.kind === 169 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 134 /* ConstructorKeyword */ && location.parent.kind === 170 /* 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 === 133 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 134 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 169 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 170 /* 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 === 169 /* Constructor */) { + if (functionDeclaration_1.kind === 170 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 172 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 173 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } if (signature) { @@ -138486,7 +141233,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 224 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 225 /* 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 @@ -138509,7 +141256,7 @@ var ts; } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(151 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); @@ -138530,9 +141277,9 @@ var ts; } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 259 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 260 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 141 /* NamespaceKeyword */ : 140 /* ModuleKeyword */)); + displayParts.push(ts.keywordPart(isNamespace ? 142 /* NamespaceKeyword */ : 141 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -138551,7 +141298,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 161 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 162 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -138559,21 +141306,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 173 /* ConstructSignature */) { + if (declaration.kind === 174 /* ConstructSignature */) { displayParts.push(ts.keywordPart(103 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 172 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 173 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 257 /* TypeAliasDeclaration */) { + else if (declaration.kind === 258 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(150 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(151 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -138585,7 +141332,7 @@ 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) === 294 /* EnumMember */) { + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 297 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -138621,17 +141368,17 @@ var ts; } if (symbol.declarations) { switch (symbol.declarations[0].kind) { - case 262 /* NamespaceExportDeclaration */: + case 263 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(141 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(142 /* NamespaceKeyword */)); break; - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); break; - case 273 /* ExportSpecifier */: + case 274 /* ExportSpecifier */: displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); break; default: @@ -138641,13 +141388,13 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 263 /* ImportEqualsDeclaration */) { + if (declaration.kind === 264 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); displayParts.push(ts.operatorPart(63 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(144 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(145 /* 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 */)); @@ -138728,10 +141475,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 === 300 /* SourceFile */; })) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 303 /* SourceFile */; })) { for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (!declaration.parent || declaration.parent.kind !== 219 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 220 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -138849,16 +141596,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 211 /* FunctionExpression */) { + if (declaration.kind === 212 /* FunctionExpression */) { return true; } - if (declaration.kind !== 252 /* VariableDeclaration */ && declaration.kind !== 254 /* FunctionDeclaration */) { + if (declaration.kind !== 253 /* VariableDeclaration */ && declaration.kind !== 255 /* 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 === 300 /* SourceFile */ || parent.kind === 260 /* ModuleBlock */) { + if (parent.kind === 303 /* SourceFile */ || parent.kind === 261 /* ModuleBlock */) { return false; } } @@ -138899,7 +141646,7 @@ var ts; options.allowNonTsExtensions = true; // if jsx is specified then treat file as .tsx var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts"); - var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 + var sourceFile = ts.createSourceFile(inputFileName, input, ts.getEmitScriptTarget(options)); if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; } @@ -138963,7 +141710,7 @@ var ts; 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) { + var _loop_10 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -138982,7 +141729,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_9(opt); + _loop_10(opt); } return options; } @@ -139158,10 +141905,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 283 /* JsxAttribute */: - case 278 /* JsxOpeningElement */: - case 279 /* JsxClosingElement */: - case 277 /* JsxSelfClosingElement */: + case 284 /* JsxAttribute */: + case 279 /* JsxOpeningElement */: + case 280 /* JsxClosingElement */: + case 278 /* 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 === 79 /* Identifier */; } @@ -139355,7 +142102,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 158 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 159 /* LastToken */; token++) { if (token !== 1 /* EndOfFileToken */) { allTokens.push(token); } @@ -139370,9 +142117,9 @@ var ts; var anyToken = { tokens: allTokens, isSpecific: false }; 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 keywords = tokenRangeFromRange(81 /* FirstKeyword */, 159 /* LastKeyword */); var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); - var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 158 /* OfKeyword */, 127 /* AsKeyword */, 138 /* IsKeyword */]; + var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 159 /* OfKeyword */, 127 /* AsKeyword */, 139 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, @@ -139446,11 +142193,11 @@ var ts; // 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", [135 /* GetKeyword */, 147 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterGetSetInMember", [136 /* GetKeyword */, 148 /* 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("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 132 /* 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. @@ -139458,8 +142205,8 @@ var ts; rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 130 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 130 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 131 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements @@ -139470,34 +142217,34 @@ var ts; 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", [140 /* ModuleKeyword */, 144 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [141 /* ModuleKeyword */, 145 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ 126 /* AbstractKeyword */, 84 /* ClassKeyword */, - 134 /* DeclareKeyword */, + 135 /* DeclareKeyword */, 88 /* DefaultKeyword */, 92 /* EnumKeyword */, 93 /* ExportKeyword */, 94 /* ExtendsKeyword */, - 135 /* GetKeyword */, + 136 /* GetKeyword */, 117 /* ImplementsKeyword */, 100 /* ImportKeyword */, 118 /* InterfaceKeyword */, - 140 /* ModuleKeyword */, - 141 /* NamespaceKeyword */, + 141 /* ModuleKeyword */, + 142 /* NamespaceKeyword */, 121 /* PrivateKeyword */, 123 /* PublicKeyword */, 122 /* ProtectedKeyword */, - 143 /* ReadonlyKeyword */, - 147 /* SetKeyword */, + 144 /* ReadonlyKeyword */, + 148 /* SetKeyword */, 124 /* StaticKeyword */, - 150 /* TypeKeyword */, - 154 /* FromKeyword */, - 139 /* KeyOfKeyword */, - 136 /* InferKeyword */, + 151 /* TypeKeyword */, + 155 /* FromKeyword */, + 140 /* KeyOfKeyword */, + 137 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 154 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 155 /* 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 @@ -139528,8 +142275,8 @@ var ts; 123 /* PublicKeyword */, 121 /* PrivateKeyword */, 122 /* ProtectedKeyword */, - 135 /* GetKeyword */, - 147 /* SetKeyword */, + 136 /* GetKeyword */, + 148 /* SetKeyword */, 22 /* OpenBracketToken */, 41 /* AsteriskToken */, ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), @@ -139540,8 +142287,8 @@ var ts; // 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", 133 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 133 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 134 /* 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 @@ -139615,11 +142362,11 @@ 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(130 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* 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", 97 /* ForKeyword */, 131 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 132 /* 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 */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), @@ -139683,54 +142430,54 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 240 /* ForStatement */; + return context.contextNode.kind === 241 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 220 /* ConditionalExpression */: - case 187 /* ConditionalType */: - case 227 /* AsExpression */: - case 273 /* ExportSpecifier */: - case 268 /* ImportSpecifier */: - case 175 /* TypePredicate */: - case 185 /* UnionType */: - case 186 /* IntersectionType */: + case 221 /* ConditionalExpression */: + case 188 /* ConditionalType */: + case 228 /* AsExpression */: + case 274 /* ExportSpecifier */: + case 269 /* ImportSpecifier */: + case 176 /* TypePredicate */: + case 186 /* UnionType */: + case 187 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 201 /* BindingElement */: + case 202 /* BindingElement */: // equals in type X = ... // falls through - case 257 /* TypeAliasDeclaration */: + case 258 /* TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: // equal in export = 1 // falls through - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: // equal in let a = 0 // falls through - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: // equal in p = 0 // falls through - case 162 /* Parameter */: - case 294 /* EnumMember */: - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: + case 163 /* Parameter */: + case 297 /* EnumMember */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 161 /* TypeParameter */: + case 162 /* 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 242 /* ForOfStatement */: - return context.currentTokenSpan.kind === 158 /* OfKeyword */ || context.nextTokenSpan.kind === 158 /* OfKeyword */; + case 243 /* ForOfStatement */: + return context.currentTokenSpan.kind === 159 /* OfKeyword */ || context.nextTokenSpan.kind === 159 /* OfKeyword */; } return false; } @@ -139742,22 +142489,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 165 /* PropertyDeclaration */ || - contextKind === 164 /* PropertySignature */ || - contextKind === 162 /* Parameter */ || - contextKind === 252 /* VariableDeclaration */ || + return contextKind === 166 /* PropertyDeclaration */ || + contextKind === 165 /* PropertySignature */ || + contextKind === 163 /* Parameter */ || + contextKind === 253 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 220 /* ConditionalExpression */ || - context.contextNode.kind === 187 /* ConditionalType */; + return context.contextNode.kind === 221 /* ConditionalExpression */ || + context.contextNode.kind === 188 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 199 /* ObjectBindingPattern */ || - context.contextNode.kind === 193 /* MappedType */ || + return context.contextNode.kind === 200 /* ObjectBindingPattern */ || + context.contextNode.kind === 194 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -139783,34 +142530,34 @@ var ts; return true; } switch (node.kind) { - case 233 /* Block */: - case 261 /* CaseBlock */: - case 203 /* ObjectLiteralExpression */: - case 260 /* ModuleBlock */: + case 234 /* Block */: + case 262 /* CaseBlock */: + case 204 /* ObjectLiteralExpression */: + case 261 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 254 /* FunctionDeclaration */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 255 /* FunctionDeclaration */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 172 /* CallSignature */: - case 211 /* FunctionExpression */: - case 169 /* Constructor */: - case 212 /* ArrowFunction */: + case 173 /* CallSignature */: + case 212 /* FunctionExpression */: + case 170 /* Constructor */: + case 213 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 256 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 257 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -139819,40 +142566,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 254 /* FunctionDeclaration */ || context.contextNode.kind === 211 /* FunctionExpression */; + return context.contextNode.kind === 255 /* FunctionDeclaration */ || context.contextNode.kind === 212 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - 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 */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: + case 259 /* EnumDeclaration */: + case 181 /* TypeLiteral */: + case 260 /* ModuleDeclaration */: + case 271 /* ExportDeclaration */: + case 272 /* NamedExports */: + case 265 /* ImportDeclaration */: + case 268 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 255 /* ClassDeclaration */: - case 259 /* ModuleDeclaration */: - case 258 /* EnumDeclaration */: - case 290 /* CatchClause */: - case 260 /* ModuleBlock */: - case 247 /* SwitchStatement */: + case 256 /* ClassDeclaration */: + case 260 /* ModuleDeclaration */: + case 259 /* EnumDeclaration */: + case 291 /* CatchClause */: + case 261 /* ModuleBlock */: + case 248 /* SwitchStatement */: return true; - case 233 /* Block */: { + case 234 /* 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 !== 212 /* ArrowFunction */ && blockParent.kind !== 211 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 213 /* ArrowFunction */ && blockParent.kind !== 212 /* FunctionExpression */) { return true; } } @@ -139861,32 +142608,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - 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 */: + case 238 /* IfStatement */: + case 248 /* SwitchStatement */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 240 /* WhileStatement */: + case 251 /* TryStatement */: + case 239 /* DoStatement */: + case 247 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 290 /* CatchClause */: + case 291 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 203 /* ObjectLiteralExpression */; + return context.contextNode.kind === 204 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 206 /* CallExpression */; + return context.contextNode.kind === 207 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 207 /* NewExpression */; + return context.contextNode.kind === 208 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -139901,10 +142648,10 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 212 /* ArrowFunction */; + return context.contextNode.kind === 213 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 198 /* ImportType */; + return context.contextNode.kind === 199 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; @@ -139913,19 +142660,19 @@ var ts; return context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 276 /* JsxElement */ && context.contextNode.kind !== 280 /* JsxFragment */; + return context.contextNode.kind !== 277 /* JsxElement */ && context.contextNode.kind !== 281 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 286 /* JsxExpression */ || context.contextNode.kind === 285 /* JsxSpreadAttribute */; + return context.contextNode.kind === 287 /* JsxExpression */ || context.contextNode.kind === 286 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 283 /* JsxAttribute */; + return context.nextTokenParent.kind === 284 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 283 /* JsxAttribute */; + return context.contextNode.kind === 284 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 277 /* JsxSelfClosingElement */; + return context.contextNode.kind === 278 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -139940,45 +142687,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 163 /* Decorator */; + return node.kind === 164 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 253 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 254 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 259 /* ModuleDeclaration */; + return context.contextNode.kind === 260 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 180 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 181 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 173 /* ConstructSignature */; + return context.contextNode.kind === 174 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - 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 */: + case 177 /* TypeReference */: + case 210 /* TypeAssertionExpression */: + case 258 /* TypeAliasDeclaration */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: + case 227 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -139989,28 +142736,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 209 /* TypeAssertionExpression */; + return context.contextNode.kind === 210 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 215 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 216 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 222 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 223 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 228 /* NonNullExpression */; + return context.contextNode.kind === 229 /* NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 237 /* IfStatement */: - case 240 /* ForStatement */: - case 241 /* ForInStatement */: - case 242 /* ForOfStatement */: - case 238 /* DoStatement */: - case 239 /* WhileStatement */: + case 238 /* IfStatement */: + case 241 /* ForStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 239 /* DoStatement */: + case 240 /* WhileStatement */: return true; default: return false; @@ -140035,12 +142782,12 @@ var ts; return nextTokenKind === 19 /* CloseBraceToken */ || nextTokenKind === 1 /* EndOfFileToken */; } - if (nextTokenKind === 232 /* SemicolonClassElement */ || + if (nextTokenKind === 233 /* SemicolonClassElement */ || nextTokenKind === 26 /* SemicolonToken */) { return false; } - if (context.contextNode.kind === 256 /* InterfaceDeclaration */ || - context.contextNode.kind === 257 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 257 /* InterfaceDeclaration */ || + context.contextNode.kind === 258 /* TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -140054,9 +142801,9 @@ var ts; if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 240 /* ForStatement */ - && context.currentTokenParent.kind !== 234 /* EmptyStatement */ - && context.currentTokenParent.kind !== 232 /* SemicolonClassElement */ + return context.currentTokenParent.kind !== 241 /* ForStatement */ + && context.currentTokenParent.kind !== 235 /* EmptyStatement */ + && context.currentTokenParent.kind !== 233 /* SemicolonClassElement */ && nextTokenKind !== 22 /* OpenBracketToken */ && nextTokenKind !== 20 /* OpenParenToken */ && nextTokenKind !== 39 /* PlusToken */ @@ -140064,7 +142811,7 @@ var ts; && nextTokenKind !== 43 /* SlashToken */ && nextTokenKind !== 13 /* RegularExpressionLiteral */ && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 221 /* TemplateExpression */ + && nextTokenKind !== 222 /* TemplateExpression */ && nextTokenKind !== 15 /* TemplateHead */ && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ && nextTokenKind !== 24 /* DotToken */; @@ -140155,12 +142902,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 158 /* LastKeyword */ && column <= 158 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 159 /* LastKeyword */ && column <= 159 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 158 /* LastToken */ + 1; + var mapRowLength = 159 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -140348,17 +143095,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 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 260 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 300 /* SourceFile */: - case 233 /* Block */: - case 260 /* ModuleBlock */: + return !!body && body.kind === 261 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 303 /* SourceFile */: + case 234 /* Block */: + case 261 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 290 /* CatchClause */: + case 291 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -140518,11 +143265,11 @@ var ts; var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { indentTriviaItems(leadingTrivia, indentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); + if (options.trimTrailingWhitespace !== false) { + trimTrailingWhitespacesForRemainingRange(leadingTrivia); + } } } - if (options.trimTrailingWhitespace !== false) { - trimTrailingWhitespacesForRemainingRange(); - } return edits; // local functions /** Tries to compute the indentation for a list element. @@ -140587,19 +143334,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - 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 */: + case 256 /* ClassDeclaration */: return 84 /* ClassKeyword */; + case 257 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; + case 255 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; + case 259 /* EnumDeclaration */: return 259 /* EnumDeclaration */; + case 171 /* GetAccessor */: return 136 /* GetKeyword */; + case 172 /* SetAccessor */: return 148 /* SetKeyword */; + case 168 /* MethodDeclaration */: if (node.asteriskToken) { return 41 /* AsteriskToken */; } // falls through - case 165 /* PropertyDeclaration */: - case 162 /* Parameter */: + case 166 /* PropertyDeclaration */: + case 163 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -140656,16 +143403,16 @@ var ts; case 43 /* SlashToken */: case 31 /* GreaterThanToken */: switch (container.kind) { - case 278 /* JsxOpeningElement */: - case 279 /* JsxClosingElement */: - case 277 /* JsxSelfClosingElement */: - case 226 /* ExpressionWithTypeArguments */: + case 279 /* JsxOpeningElement */: + case 280 /* JsxClosingElement */: + case 278 /* JsxSelfClosingElement */: + case 227 /* ExpressionWithTypeArguments */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 193 /* MappedType */) { + if (container.kind !== 194 /* MappedType */) { return false; } break; @@ -140768,11 +143515,11 @@ var ts; return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 163 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 164 /* 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 === 202 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 203 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -141091,12 +143838,27 @@ var ts; return -1; } /** - * Trimming will be done for lines after the previous range + * Trimming will be done for lines after the previous range. + * Exclude comments as they had been previously processed. */ - function trimTrailingWhitespacesForRemainingRange() { - var startPosition = previousRange ? previousRange.end : originalRange.pos; - var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line; - var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line; + function trimTrailingWhitespacesForRemainingRange(trivias) { + var startPos = previousRange ? previousRange.end : originalRange.pos; + for (var _i = 0, trivias_1 = trivias; _i < trivias_1.length; _i++) { + var trivia = trivias_1[_i]; + if (ts.isComment(trivia.kind)) { + if (startPos < trivia.pos) { + trimTrailingWitespacesForPositions(startPos, trivia.pos - 1, previousRange); + } + startPos = trivia.end + 1; + } + } + if (startPos < originalRange.end) { + trimTrailingWitespacesForPositions(startPos, originalRange.end, previousRange); + } + } + function trimTrailingWitespacesForPositions(startPos, endPos, previousRange) { + var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(endPos).line; trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange); } function recordDelete(start, len) { @@ -141205,12 +143967,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 169 /* Constructor */: - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: - case 212 /* ArrowFunction */: + case 170 /* Constructor */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 213 /* ArrowFunction */: if (node.typeParameters === list) { return 29 /* LessThanToken */; } @@ -141218,8 +143980,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 206 /* CallExpression */: - case 207 /* NewExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } @@ -141227,12 +143989,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 176 /* TypeReference */: + case 177 /* TypeReference */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } break; - case 180 /* TypeLiteral */: + case 181 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -141350,7 +144112,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 219 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 220 /* 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 */) { @@ -141523,7 +144285,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 === 300 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 303 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -141571,7 +144333,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 237 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 238 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -141652,40 +144414,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 176 /* TypeReference */: + case 177 /* TypeReference */: return getList(node.typeArguments); - case 203 /* ObjectLiteralExpression */: + case 204 /* ObjectLiteralExpression */: return getList(node.properties); - case 202 /* ArrayLiteralExpression */: + case 203 /* ArrayLiteralExpression */: return getList(node.elements); - case 180 /* TypeLiteral */: + case 181 /* TypeLiteral */: return getList(node.members); - 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 */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 173 /* CallSignature */: + case 170 /* Constructor */: + case 179 /* ConstructorType */: + case 174 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 255 /* ClassDeclaration */: - case 224 /* ClassExpression */: - case 256 /* InterfaceDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 339 /* JSDocTemplateTag */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 342 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 207 /* NewExpression */: - case 206 /* CallExpression */: + case 208 /* NewExpression */: + case 207 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 253 /* VariableDeclarationList */: + case 254 /* VariableDeclarationList */: return getList(node.declarations); - case 267 /* NamedImports */: - case 271 /* NamedExports */: + case 268 /* NamedImports */: + case 272 /* NamedExports */: return getList(node.elements); - case 199 /* ObjectBindingPattern */: - case 200 /* ArrayBindingPattern */: + case 200 /* ObjectBindingPattern */: + case 201 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -141708,7 +144470,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 253 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 254 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -141781,91 +144543,96 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - 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 */: + case 237 /* ExpressionStatement */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: + case 259 /* EnumDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 203 /* ArrayLiteralExpression */: + case 234 /* Block */: + case 261 /* ModuleBlock */: + case 204 /* ObjectLiteralExpression */: + case 181 /* TypeLiteral */: + case 194 /* MappedType */: + case 183 /* TupleType */: + case 262 /* CaseBlock */: + case 289 /* DefaultClause */: + case 288 /* CaseClause */: + case 211 /* ParenthesizedExpression */: + case 205 /* PropertyAccessExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: + case 236 /* VariableStatement */: + case 270 /* ExportAssignment */: + case 246 /* ReturnStatement */: + case 221 /* ConditionalExpression */: + case 201 /* ArrayBindingPattern */: + case 200 /* ObjectBindingPattern */: + case 279 /* JsxOpeningElement */: + case 282 /* JsxOpeningFragment */: + case 278 /* JsxSelfClosingElement */: + case 287 /* JsxExpression */: + case 167 /* MethodSignature */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 163 /* Parameter */: + case 178 /* FunctionType */: + case 179 /* ConstructorType */: + case 190 /* ParenthesizedType */: + case 209 /* TaggedTemplateExpression */: + case 217 /* AwaitExpression */: + case 272 /* NamedExports */: + case 268 /* NamedImports */: + case 274 /* ExportSpecifier */: + case 269 /* ImportSpecifier */: + case 166 /* PropertyDeclaration */: return true; - case 252 /* VariableDeclaration */: - case 291 /* PropertyAssignment */: - case 219 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 203 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 253 /* VariableDeclaration */: + case 294 /* PropertyAssignment */: + case 220 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 204 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind !== 219 /* BinaryExpression */) { + if (parent.kind === 220 /* BinaryExpression */ && sourceFile && child && childKind === 277 /* JsxElement */) { + var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line; + var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line; + return parentStartLine !== childStartLine; + } + if (parent.kind !== 220 /* BinaryExpression */) { return true; } break; - 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 */) { + case 239 /* DoStatement */: + case 240 /* WhileStatement */: + case 242 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 241 /* ForStatement */: + case 238 /* IfStatement */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 168 /* MethodDeclaration */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + return childKind !== 234 /* Block */; + case 213 /* ArrowFunction */: + if (sourceFile && childKind === 211 /* ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - 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 childKind !== 234 /* Block */; + case 271 /* ExportDeclaration */: + return childKind !== 272 /* NamedExports */; + case 265 /* ImportDeclaration */: + return childKind !== 266 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 268 /* NamedImports */); + case 277 /* JsxElement */: + return childKind !== 280 /* JsxClosingElement */; + case 281 /* JsxFragment */: + return childKind !== 283 /* JsxClosingFragment */; + case 187 /* IntersectionType */: + case 186 /* UnionType */: + if (childKind === 181 /* TypeLiteral */ || childKind === 183 /* TupleType */) { return false; } break; @@ -141876,11 +144643,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 245 /* ReturnStatement */: - case 249 /* ThrowStatement */: - case 243 /* ContinueStatement */: - case 244 /* BreakStatement */: - return parent.kind !== 233 /* Block */; + case 246 /* ReturnStatement */: + case 250 /* ThrowStatement */: + case 244 /* ContinueStatement */: + case 245 /* BreakStatement */: + return parent.kind !== 234 /* Block */; default: return false; } @@ -142097,7 +144864,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 === 203 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 204 /* ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -142304,7 +145071,7 @@ var ts; } } else { - endNode = (_a = (node.kind === 252 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 253 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; @@ -142470,18 +145237,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 255 /* ClassDeclaration */: - case 259 /* ModuleDeclaration */: + case 256 /* ClassDeclaration */: + case 260 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: case 10 /* StringLiteral */: case 79 /* Identifier */: return { prefix: ", " }; - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; case 93 /* ExportKeyword */: return { prefix: " " }; - case 162 /* Parameter */: + case 163 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -142490,7 +145257,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 212 /* ArrowFunction */) { + if (node.kind === 213 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { @@ -142504,14 +145271,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 !== 233 /* Block */) { + if (node.body.kind !== 234 /* Block */) { // `() => 0` => `function f() { return 0; }` 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 === 211 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 212 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -142630,7 +145397,7 @@ var ts; ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. - var _loop_10 = function (sourceFile, node) { + var _loop_11 = function (sourceFile, node) { if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { if (ts.isArray(node)) { this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node)); @@ -142643,7 +145410,7 @@ var ts; var this_1 = this; for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; - _loop_10(sourceFile, node); + _loop_11(sourceFile, node); } deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); @@ -142702,14 +145469,14 @@ var ts; // order changes by start position // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); - var _loop_11 = function (i) { + var _loop_12 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_11(i); + _loop_12(i); } var textChanges = ts.mapDefined(normalized, function (c) { var span = ts.createTextSpanFromRange(c.range); @@ -142775,14 +145542,19 @@ var ts; if (delta === undefined) { delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? (formatOptions.indentSize || 0) : 0; } - var file = { text: text, getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); } }; + var file = { + text: text, + getLineAndCharacterOfPosition: function (pos) { + return ts.getLineAndCharacterOfPosition(this, pos); + } + }; var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, __assign(__assign({}, formatContext), { options: formatOptions })); return applyChanges(text, changes); } /** Note: output node may be mutated input node. */ function getNonformattedText(node, sourceFile, newLineCharacter) { var writer = createWriter(newLineCharacter); - var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + var newLine = ts.getNewLineKind(newLineCharacter); ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, @@ -143064,14 +145836,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 160 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 161 /* 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 162 /* Parameter */: { + case 163 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -143086,17 +145858,17 @@ var ts; } break; } - case 264 /* ImportDeclaration */: - case 263 /* ImportEqualsDeclaration */: + case 265 /* ImportDeclaration */: + case 264 /* 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 201 /* BindingElement */: + case 202 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 200 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 201 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -143104,13 +145876,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 161 /* TypeParameter */: + case 162 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 268 /* ImportSpecifier */: + case 269 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -143119,7 +145891,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 266 /* NamespaceImport */: + case 267 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; case 26 /* SemicolonToken */: @@ -143128,8 +145900,8 @@ var ts; case 98 /* FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 255 /* ClassDeclaration */: - case 254 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: + case 255 /* FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -143180,13 +145952,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 264 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 265 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 290 /* CatchClause */) { + if (parent.kind === 291 /* 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; @@ -143197,14 +145969,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 242 /* ForOfStatement */: - case 241 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 242 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 240 /* ForStatement */: + case 241 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -143247,21 +146019,16 @@ var ts; (function (codefix) { var errorCodeToFixes = ts.createMultiMap(); var fixIdToRegistration = new ts.Map(); - function diagnosticToString(diag) { - return ts.isArray(diag) - ? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1)) - : ts.getLocaleSpecificMessage(diag); - } function createCodeFixActionWithoutFixAll(fixName, changes, description) { - return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined); + return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined); } codefix.createCodeFixActionWithoutFixAll = createCodeFixActionWithoutFixAll; function createCodeFixAction(fixName, changes, description, fixId, fixAllDescription, command) { - return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command); + return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, fixId, ts.diagnosticToString(fixAllDescription), command); } codefix.createCodeFixAction = createCodeFixAction; function createCodeFixActionMaybeFixAll(fixName, changes, description, fixId, fixAllDescription, command) { - return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, fixAllDescription && diagnosticToString(fixAllDescription), command); + return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, fixId, fixAllDescription && ts.diagnosticToString(fixAllDescription), command); } codefix.createCodeFixActionMaybeFixAll = createCodeFixActionMaybeFixAll; function createCodeFixActionWorker(fixName, description, changes, fixId, fixAllDescription, command) { @@ -143390,8 +146157,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(153 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -143534,7 +146301,7 @@ var ts; errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getAwaitErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -143550,7 +146317,7 @@ var ts; var checker = context.program.getTypeChecker(); var fixedDeclarations = new ts.Set(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getAwaitErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } @@ -143560,6 +146327,12 @@ var ts; }); }, }); + function getAwaitErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { + var expression = ts.getFixableErrorSpanExpression(sourceFile, span); + return expression + && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) + && isInsideAwaitableBody(expression) ? expression : undefined; + } function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); @@ -143595,21 +146368,6 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { - var token = ts.getTokenAtPosition(sourceFile, span.start); - // Checker has already done work to determine that await might be possible, and has attached - // related info to the node, so start by finding the expression that exactly matches up - // with the diagnostic range. - var expression = ts.findAncestor(token, function (node) { - if (node.getStart(sourceFile) < span.start || node.getEnd() > ts.textSpanEnd(span)) { - return "quit"; - } - return ts.isExpression(node) && ts.textSpansEqual(span, ts.createTextSpanFromNode(node, sourceFile)); - }); - return expression - && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) ? expression : undefined; - } function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); if (!identifiers) { @@ -143617,14 +146375,14 @@ var ts; } var isCompleteFix = identifiers.isCompleteFix; var initializers; - var _loop_12 = function (identifier) { + var _loop_13 = function (identifier) { var symbol = checker.getSymbolAtLocation(identifier); if (!symbol) { return "continue"; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 235 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 236 /* VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || @@ -143650,7 +146408,7 @@ var ts; }; for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { var identifier = _a[_i]; - _loop_12(identifier); + _loop_13(identifier); } return initializers && { initializers: initializers, @@ -143702,10 +146460,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 === 254 /* FunctionDeclaration */ || - ancestor.parent.kind === 211 /* FunctionExpression */ || - ancestor.parent.kind === 212 /* ArrowFunction */ || - ancestor.parent.kind === 167 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 255 /* FunctionDeclaration */ || + ancestor.parent.kind === 212 /* FunctionExpression */ || + ancestor.parent.kind === 213 /* ArrowFunction */ || + ancestor.parent.kind === 168 /* MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -143824,10 +146582,10 @@ var ts; function isPossiblyPartOfDestructuring(node) { switch (node.kind) { case 79 /* Identifier */: - case 202 /* ArrayLiteralExpression */: - case 203 /* ObjectLiteralExpression */: - case 291 /* PropertyAssignment */: - case 292 /* ShorthandPropertyAssignment */: + case 203 /* ArrayLiteralExpression */: + case 204 /* ObjectLiteralExpression */: + case 294 /* PropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -143842,7 +146600,7 @@ var ts; function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { case 79 /* Identifier */: - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -143891,9 +146649,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 165 /* PropertyDeclaration */ && + if (declaration.kind === 166 /* PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 134 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 135 /* DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -143941,9 +146699,6 @@ var ts; }); function makeChange(changeTracker, sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (!ts.isIdentifier(token)) { - return ts.Debug.fail("add-name-to-nameless-parameter operates on identifiers, but got a " + ts.Debug.formatSyntaxKind(token.kind)); - } var param = token.parent; if (!ts.isParameter(param)) { return ts.Debug.fail("Tried to add a parameter name to a non-parameter: " + ts.Debug.formatSyntaxKind(token.kind)); @@ -143951,9 +146706,112 @@ var ts; var i = param.parent.parameters.indexOf(param); ts.Debug.assert(!param.type, "Tried to add a parameter name to a parameter that already had one."); ts.Debug.assert(i > -1, "Parameter not found in parent parameter list."); + var typeNode = ts.factory.createTypeReferenceNode(param.name, /*typeArguments*/ undefined); var replacement = ts.factory.createParameterDeclaration( - /*decorators*/ undefined, param.modifiers, param.dotDotDotToken, "arg" + i, param.questionToken, ts.factory.createTypeReferenceNode(token, /*typeArguments*/ undefined), param.initializer); - changeTracker.replaceNode(sourceFile, token, replacement); + /*decorators*/ undefined, param.modifiers, param.dotDotDotToken, "arg" + i, param.questionToken, param.dotDotDotToken ? ts.factory.createArrayTypeNode(typeNode) : typeNode, param.initializer); + changeTracker.replaceNode(sourceFile, param, replacement); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + var addOptionalPropertyUndefined = "addOptionalPropertyUndefined"; + var errorCodes = [ + ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target.code, + ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code, + ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var typeChecker = context.program.getTypeChecker(); + var toAdd = getPropertiesToAdd(context.sourceFile, context.span, typeChecker); + if (!toAdd.length) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedToOptionalProperty(t, toAdd); }); + return [codefix.createCodeFixActionWithoutFixAll(addOptionalPropertyUndefined, changes, ts.Diagnostics.Add_undefined_to_optional_property_type)]; + }, + fixIds: [addOptionalPropertyUndefined], + }); + function getPropertiesToAdd(file, span, checker) { + var _a, _b; + var sourceTarget = getSourceTarget(ts.getFixableErrorSpanExpression(file, span), checker); + if (!sourceTarget) { + return ts.emptyArray; + } + var sourceNode = sourceTarget.source, targetNode = sourceTarget.target; + var target = shouldUseParentTypeOfProperty(sourceNode, targetNode, checker) + ? checker.getTypeAtLocation(targetNode.expression) + : checker.getTypeAtLocation(targetNode); + if ((_b = (_a = target.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return ts.getSourceFileOfNode(d).fileName.match(/\.d\.ts$/); })) { + return ts.emptyArray; + } + return checker.getExactOptionalProperties(target); + } + function shouldUseParentTypeOfProperty(sourceNode, targetNode, checker) { + return ts.isPropertyAccessExpression(targetNode) + && !!checker.getExactOptionalProperties(checker.getTypeAtLocation(targetNode.expression)).length + && checker.getTypeAtLocation(sourceNode) === checker.getUndefinedType(); + } + /** + * Find the source and target of the incorrect assignment. + * The call is recursive for property assignments. + */ + function getSourceTarget(errorNode, checker) { + var _a; + if (!errorNode) { + return undefined; + } + else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* EqualsToken */) { + return { source: errorNode.parent.right, target: errorNode.parent.left }; + } + else if (ts.isVariableDeclaration(errorNode.parent) && errorNode.parent.initializer) { + return { source: errorNode.parent.initializer, target: errorNode.parent.name }; + } + else if (ts.isCallExpression(errorNode.parent)) { + var n = checker.getSymbolAtLocation(errorNode.parent.expression); + if (!(n === null || n === void 0 ? void 0 : n.valueDeclaration) || !ts.isFunctionLikeKind(n.valueDeclaration.kind)) + return undefined; + if (!ts.isExpression(errorNode)) + return undefined; + var i = errorNode.parent.arguments.indexOf(errorNode); + if (i === -1) + return undefined; + var name = n.valueDeclaration.parameters[i].name; + if (ts.isIdentifier(name)) + return { source: errorNode, target: name }; + } + else if (ts.isPropertyAssignment(errorNode.parent) && ts.isIdentifier(errorNode.parent.name) || + ts.isShorthandPropertyAssignment(errorNode.parent)) { + var parentTarget = getSourceTarget(errorNode.parent.parent, checker); + if (!parentTarget) + return undefined; + var prop = checker.getPropertyOfType(checker.getTypeAtLocation(parentTarget.target), errorNode.parent.name.text); + var declaration = (_a = prop === null || prop === void 0 ? void 0 : prop.declarations) === null || _a === void 0 ? void 0 : _a[0]; + if (!declaration) + return undefined; + return { + source: ts.isPropertyAssignment(errorNode.parent) ? errorNode.parent.initializer : errorNode.parent.name, + target: declaration + }; + } + return undefined; + } + function addUndefinedToOptionalProperty(changes, toAdd) { + for (var _i = 0, toAdd_1 = toAdd; _i < toAdd_1.length; _i++) { + var add = toAdd_1[_i]; + var d = add.valueDeclaration; + if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) { + var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 186 /* UnionType */ ? d.type.types : [d.type], true), [ + ts.factory.createTypeReferenceNode("undefined") + ], false)); + changes.replaceNode(d.getSourceFile(), d.type, t); + } + } } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -144028,26 +146886,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 252 /* VariableDeclaration */ || - node.kind === 164 /* PropertySignature */ || - node.kind === 165 /* PropertyDeclaration */; + node.kind === 253 /* VariableDeclaration */ || + node.kind === 165 /* PropertySignature */ || + node.kind === 166 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 307 /* JSDocAllType */: - case 308 /* JSDocUnknownType */: + case 310 /* JSDocAllType */: + case 311 /* JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 311 /* JSDocOptionalType */: + case 314 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 310 /* JSDocNonNullableType */: + case 313 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 309 /* JSDocNullableType */: + case 312 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 313 /* JSDocVariadicType */: + case 316 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 312 /* JSDocFunctionType */: + case 315 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 176 /* TypeReference */: + case 177 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); @@ -144068,11 +146926,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(129 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 313 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 316 /* 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); @@ -144112,8 +146970,8 @@ var ts; var index = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 145 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 146 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 146 /* 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 */); @@ -144246,7 +147104,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 === 236 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 237 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -144297,7 +147155,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 130 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* 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); @@ -144307,14 +147165,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 233 /* Block */) { + if (arrowFunctionBody.kind === 234 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 130 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* 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); @@ -144368,7 +147226,7 @@ var ts; return propName; } if (ts.isStringLiteralLike(propName)) { - return ts.isIdentifierText(propName.text, compilerOptions.target) ? ts.factory.createIdentifier(propName.text) + return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text) : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */) : propName; } @@ -144430,21 +147288,32 @@ var ts; functionToConvert.decorators ? ts.skipTrivia(sourceFile.text, functionToConvert.decorators.end) : functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, 130 /* AsyncKeyword */, options); - var _loop_13 = function (returnStatement) { + changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, options); + var _loop_14 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { - var newNodes = transformExpression(node, transformer); + var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false); + if (hasFailed()) { + return true; // return something truthy to shortcut out of more work + } changes.replaceNodeWithNodes(sourceFile, returnStatement, newNodes); } else if (!ts.isFunctionLike(node)) { ts.forEachChild(node, visit); + if (hasFailed()) { + return true; // return something truthy to shortcut out of more work + } } }); + if (hasFailed()) { + return { value: void 0 }; + } }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var returnStatement = returnStatements_1[_i]; - _loop_13(returnStatement); + var state_5 = _loop_14(returnStatement); + if (typeof state_5 === "object") + return state_5.value; } } function getReturnStatementsWithPromiseHandlers(body, checker) { @@ -144468,9 +147337,10 @@ var ts; setOfExpressionsToReturn.add(ts.getNodeId(node)); ts.forEach(node.arguments, visit); } - else if (isPromiseReturningCallExpression(node, checker, "catch")) { + else if (isPromiseReturningCallExpression(node, checker, "catch") || + isPromiseReturningCallExpression(node, checker, "finally")) { setOfExpressionsToReturn.add(ts.getNodeId(node)); - // if .catch() is the last call in the chain, move leftward in the chain until we hit something else that should be returned + // if .catch() or .finally() is the last call in the chain, move leftward in the chain until we hit something else that should be returned ts.forEachChild(node, visit); } else if (isPromiseTypedExpression(node, checker)) { @@ -144490,6 +147360,38 @@ var ts; var nodeType = isExpressionOfName && checker.getTypeAtLocation(node); return !!(nodeType && checker.getPromisedTypeOfPromise(nodeType)); } + // NOTE: this is a mostly copy of `isReferenceToType` from checker.ts. While this violates DRY, it keeps + // `isReferenceToType` in checker local to the checker to avoid the cost of a property lookup on `ts`. + function isReferenceToType(type, target) { + return (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && type.target === target; + } + function getExplicitPromisedTypeOfPromiseReturningCallExpression(node, callback, checker) { + if (node.expression.name.escapedText === "finally") { + // for a `finally`, there's no type argument + return undefined; + } + // If the call to `then` or `catch` comes from the global `Promise` or `PromiseLike` type, we can safely use the + // type argument supplied for the callback. For other promise types we would need a more complex heuristic to determine + // which type argument is safe to use as an annotation. + var promiseType = checker.getTypeAtLocation(node.expression.expression); + if (isReferenceToType(promiseType, checker.getPromiseType()) || + isReferenceToType(promiseType, checker.getPromiseLikeType())) { + if (node.expression.name.escapedText === "then") { + if (callback === ts.elementAt(node.arguments, 0)) { + // for the `onfulfilled` callback, use the first type argument + return ts.elementAt(node.typeArguments, 0); + } + else if (callback === ts.elementAt(node.arguments, 1)) { + // for the `onrejected` callback, use the second type argument + return ts.elementAt(node.typeArguments, 1); + } + } + else { + return ts.elementAt(node.typeArguments, 0); + } + } + } function isPromiseTypedExpression(node, checker) { if (!ts.isExpression(node)) return false; @@ -144570,104 +147472,189 @@ var ts; var identifier = numVarsSameName === 0 ? name : ts.factory.createIdentifier(name.text + "_" + numVarsSameName); return createSynthIdentifier(identifier); } + function hasFailed() { + return !codeActionSucceeded; + } function silentFail() { codeActionSucceeded = false; return ts.emptyArray; } // dispatch function to recursively build the refactoring // should be kept up to date with isFixablePromiseHandler in suggestionDiagnostics.ts - function transformExpression(node, transformer, prevArgName) { + /** + * @param hasContinuation Whether another `then`, `catch`, or `finally` continuation follows the continuation to which this expression belongs. + * @param continuationArgName The argument name for the continuation that follows this call. + */ + function transformExpression(returnContextNode, node, transformer, hasContinuation, continuationArgName) { if (isPromiseReturningCallExpression(node, transformer.checker, "then")) { - if (node.arguments.length === 0) - return silentFail(); - return transformThen(node, transformer, prevArgName); + return transformThen(node, ts.elementAt(node.arguments, 0), ts.elementAt(node.arguments, 1), transformer, hasContinuation, continuationArgName); } if (isPromiseReturningCallExpression(node, transformer.checker, "catch")) { - return transformCatch(node, transformer, prevArgName); + return transformCatch(node, ts.elementAt(node.arguments, 0), transformer, hasContinuation, continuationArgName); + } + if (isPromiseReturningCallExpression(node, transformer.checker, "finally")) { + return transformFinally(node, ts.elementAt(node.arguments, 0), transformer, hasContinuation, continuationArgName); } if (ts.isPropertyAccessExpression(node)) { - return transformExpression(node.expression, transformer, prevArgName); + return transformExpression(returnContextNode, node.expression, transformer, hasContinuation, continuationArgName); } var nodeType = transformer.checker.getTypeAtLocation(node); if (nodeType && transformer.checker.getPromisedTypeOfPromise(nodeType)) { - ts.Debug.assertNode(node.original.parent, ts.isPropertyAccessExpression); - return transformPromiseExpressionOfPropertyAccess(node, transformer, prevArgName); + ts.Debug.assertNode(ts.getOriginalNode(node).parent, ts.isPropertyAccessExpression); + return transformPromiseExpressionOfPropertyAccess(returnContextNode, node, transformer, hasContinuation, continuationArgName); } return silentFail(); } - function transformCatch(node, transformer, prevArgName) { - var func = ts.singleOrUndefined(node.arguments); - var argName = func ? getArgBindingName(func, transformer) : undefined; + function isNullOrUndefined(_a, node) { + var checker = _a.checker; + if (node.kind === 104 /* NullKeyword */) + return true; + if (ts.isIdentifier(node) && !ts.isGeneratedIdentifier(node) && ts.idText(node) === "undefined") { + var symbol = checker.getSymbolAtLocation(node); + return !symbol || checker.isUndefinedSymbol(symbol); + } + return false; + } + function createUniqueSynthName(prevArgName) { + var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */); + return createSynthIdentifier(renamedPrevArg); + } + function getPossibleNameForVarDecl(node, transformer, continuationArgName) { var possibleNameForVarDecl; - // If there is another call in the chain after the .catch() we are transforming, we will need to save the result of both paths (try block and catch block) - // To do this, we will need to synthesize a variable that we were not aware of while we were adding identifiers to the synthNamesMap - // We will use the prevArgName and then update the synthNamesMap with a new variable name for the next transformation step - if (prevArgName && !shouldReturn(node, transformer)) { - if (isSynthIdentifier(prevArgName)) { - possibleNameForVarDecl = prevArgName; + // If there is another call in the chain after the .catch() or .finally() we are transforming, we will need to save the result of both paths + // (try block and catch/finally block). To do this, we will need to synthesize a variable that we were not aware of while we were adding + // identifiers to the synthNamesMap. We will use the continuationArgName and then update the synthNamesMap with a new variable name for + // the next transformation step + if (continuationArgName && !shouldReturn(node, transformer)) { + if (isSynthIdentifier(continuationArgName)) { + possibleNameForVarDecl = continuationArgName; transformer.synthNamesMap.forEach(function (val, key) { - if (val.identifier.text === prevArgName.identifier.text) { - var newSynthName = createUniqueSynthName(prevArgName); + if (val.identifier.text === continuationArgName.identifier.text) { + var newSynthName = createUniqueSynthName(continuationArgName); transformer.synthNamesMap.set(key, newSynthName); } }); } else { - possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), prevArgName.types); + possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), continuationArgName.types); } // We are about to write a 'let' variable declaration, but `transformExpression` for both - // the try block and catch block will assign to this name. Setting this flag indicates + // the try block and catch/finally block will assign to this name. Setting this flag indicates // that future assignments should be written as `name = value` instead of `const name = value`. - possibleNameForVarDecl.hasBeenDeclared = true; + declareSynthIdentifier(possibleNameForVarDecl); } - var tryBlock = ts.factory.createBlock(transformExpression(node.expression, transformer, possibleNameForVarDecl)); - var transformationBody = func ? getTransformationBody(func, possibleNameForVarDecl, argName, node, transformer) : ts.emptyArray; - var catchArg = argName ? isSynthIdentifier(argName) ? argName.identifier.text : argName.bindingPattern : "e"; - var catchVariableDeclaration = ts.factory.createVariableDeclaration(catchArg); - var catchClause = ts.factory.createCatchClause(catchVariableDeclaration, ts.factory.createBlock(transformationBody)); + return possibleNameForVarDecl; + } + function finishCatchOrFinallyTransform(node, transformer, tryStatement, possibleNameForVarDecl, continuationArgName) { + var statements = []; // In order to avoid an implicit any, we will synthesize a type for the declaration using the unions of the types of both paths (try block and catch block) - var varDeclList; var varDeclIdentifier; if (possibleNameForVarDecl && !shouldReturn(node, transformer)) { - varDeclIdentifier = ts.getSynthesizedDeepClone(possibleNameForVarDecl.identifier); + varDeclIdentifier = ts.getSynthesizedDeepClone(declareSynthIdentifier(possibleNameForVarDecl)); var typeArray = possibleNameForVarDecl.types; var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */); var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); var varDecl = [ts.factory.createVariableDeclaration(varDeclIdentifier, /*exclamationToken*/ undefined, unionTypeNode)]; - varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */)); + var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */)); + statements.push(varDeclList); } - var tryStatement = ts.factory.createTryStatement(tryBlock, catchClause, /*finallyBlock*/ undefined); - var destructuredResult = prevArgName && varDeclIdentifier && isSynthBindingPattern(prevArgName) - && ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(prevArgName.bindingPattern), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier)], 2 /* Const */)); - return ts.compact([varDeclList, tryStatement, destructuredResult]); + statements.push(tryStatement); + if (continuationArgName && varDeclIdentifier && isSynthBindingPattern(continuationArgName)) { + statements.push(ts.factory.createVariableStatement( + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ + ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingPattern(continuationArgName)), + /*exclamationToken*/ undefined, + /*type*/ undefined, varDeclIdentifier) + ], 2 /* Const */))); + } + return statements; } - function createUniqueSynthName(prevArgName) { - var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */); - return createSynthIdentifier(renamedPrevArg); + /** + * @param hasContinuation Whether another `then`, `catch`, or `finally` continuation follows this continuation. + * @param continuationArgName The argument name for the continuation that follows this call. + */ + function transformFinally(node, onFinally, transformer, hasContinuation, continuationArgName) { + if (!onFinally || isNullOrUndefined(transformer, onFinally)) { + // Ignore this call as it has no effect on the result + return transformExpression(/* returnContextNode */ node, node.expression.expression, transformer, hasContinuation, continuationArgName); + } + var possibleNameForVarDecl = getPossibleNameForVarDecl(node, transformer, continuationArgName); + // Transform the left-hand-side of `.finally` into an array of inlined statements. We pass `true` for hasContinuation as `node` is the outer continuation. + var inlinedLeftHandSide = transformExpression(/*returnContextNode*/ node, node.expression.expression, transformer, /*hasContinuation*/ true, possibleNameForVarDecl); + if (hasFailed()) + return silentFail(); // shortcut out of more work + // Transform the callback argument into an array of inlined statements. We pass whether we have an outer continuation here + // as that indicates whether `return` is valid. + var inlinedCallback = transformCallbackArgument(onFinally, hasContinuation, /*continuationArgName*/ undefined, /*argName*/ undefined, node, transformer); + if (hasFailed()) + return silentFail(); // shortcut out of more work + var tryBlock = ts.factory.createBlock(inlinedLeftHandSide); + var finallyBlock = ts.factory.createBlock(inlinedCallback); + var tryStatement = ts.factory.createTryStatement(tryBlock, /*catchClause*/ undefined, finallyBlock); + return finishCatchOrFinallyTransform(node, transformer, tryStatement, possibleNameForVarDecl, continuationArgName); + } + /** + * @param hasContinuation Whether another `then`, `catch`, or `finally` continuation follows this continuation. + * @param continuationArgName The argument name for the continuation that follows this call. + */ + function transformCatch(node, onRejected, transformer, hasContinuation, continuationArgName) { + if (!onRejected || isNullOrUndefined(transformer, onRejected)) { + // Ignore this call as it has no effect on the result + return transformExpression(/* returnContextNode */ node, node.expression.expression, transformer, hasContinuation, continuationArgName); + } + var inputArgName = getArgBindingName(onRejected, transformer); + var possibleNameForVarDecl = getPossibleNameForVarDecl(node, transformer, continuationArgName); + // Transform the left-hand-side of `.then`/`.catch` into an array of inlined statements. We pass `true` for hasContinuation as `node` is the outer continuation. + var inlinedLeftHandSide = transformExpression(/*returnContextNode*/ node, node.expression.expression, transformer, /*hasContinuation*/ true, possibleNameForVarDecl); + if (hasFailed()) + return silentFail(); // shortcut out of more work + // Transform the callback argument into an array of inlined statements. We pass whether we have an outer continuation here + // as that indicates whether `return` is valid. + var inlinedCallback = transformCallbackArgument(onRejected, hasContinuation, possibleNameForVarDecl, inputArgName, node, transformer); + if (hasFailed()) + return silentFail(); // shortcut out of more work + var tryBlock = ts.factory.createBlock(inlinedLeftHandSide); + var catchClause = ts.factory.createCatchClause(inputArgName && ts.getSynthesizedDeepClone(declareSynthBindingName(inputArgName)), ts.factory.createBlock(inlinedCallback)); + var tryStatement = ts.factory.createTryStatement(tryBlock, catchClause, /*finallyBlock*/ undefined); + return finishCatchOrFinallyTransform(node, transformer, tryStatement, possibleNameForVarDecl, continuationArgName); } - function transformThen(node, transformer, prevArgName) { - var _a = node.arguments, onFulfilled = _a[0], onRejected = _a[1]; - var onFulfilledArgumentName = getArgBindingName(onFulfilled, transformer); - var transformationBody = getTransformationBody(onFulfilled, prevArgName, onFulfilledArgumentName, node, transformer); - if (onRejected) { - var onRejectedArgumentName = getArgBindingName(onRejected, transformer); - var tryBlock = ts.factory.createBlock(transformExpression(node.expression, transformer, onFulfilledArgumentName).concat(transformationBody)); - var transformationBody2 = getTransformationBody(onRejected, prevArgName, onRejectedArgumentName, node, transformer); - var catchArg = onRejectedArgumentName ? isSynthIdentifier(onRejectedArgumentName) ? onRejectedArgumentName.identifier.text : onRejectedArgumentName.bindingPattern : "e"; - var catchVariableDeclaration = ts.factory.createVariableDeclaration(catchArg); - var catchClause = ts.factory.createCatchClause(catchVariableDeclaration, ts.factory.createBlock(transformationBody2)); - return [ts.factory.createTryStatement(tryBlock, catchClause, /* finallyBlock */ undefined)]; + /** + * @param hasContinuation Whether another `then`, `catch`, or `finally` continuation follows this continuation. + * @param continuationArgName The argument name for the continuation that follows this call. + */ + function transformThen(node, onFulfilled, onRejected, transformer, hasContinuation, continuationArgName) { + if (!onFulfilled || isNullOrUndefined(transformer, onFulfilled)) { + // If we don't have an `onfulfilled` callback, try treating this as a `.catch`. + return transformCatch(node, onRejected, transformer, hasContinuation, continuationArgName); } - return transformExpression(node.expression, transformer, onFulfilledArgumentName).concat(transformationBody); + // We don't currently support transforming a `.then` with both onfulfilled and onrejected handlers, per GH#38152. + if (onRejected && !isNullOrUndefined(transformer, onRejected)) { + return silentFail(); + } + var inputArgName = getArgBindingName(onFulfilled, transformer); + // Transform the left-hand-side of `.then` into an array of inlined statements. We pass `true` for hasContinuation as `node` is the outer continuation. + var inlinedLeftHandSide = transformExpression(node.expression.expression, node.expression.expression, transformer, /*hasContinuation*/ true, inputArgName); + if (hasFailed()) + return silentFail(); // shortcut out of more work + // Transform the callback argument into an array of inlined statements. We pass whether we have an outer continuation here + // as that indicates whether `return` is valid. + var inlinedCallback = transformCallbackArgument(onFulfilled, hasContinuation, continuationArgName, inputArgName, node, transformer); + if (hasFailed()) + return silentFail(); // shortcut out of more work + return ts.concatenate(inlinedLeftHandSide, inlinedCallback); } /** * Transforms the 'x' part of `x.then(...)`, or the 'y()' part of `y().catch(...)`, where 'x' and 'y()' are Promises. */ - function transformPromiseExpressionOfPropertyAccess(node, transformer, prevArgName) { - if (shouldReturn(node, transformer)) { - return [ts.factory.createReturnStatement(ts.getSynthesizedDeepClone(node))]; + function transformPromiseExpressionOfPropertyAccess(returnContextNode, node, transformer, hasContinuation, continuationArgName) { + if (shouldReturn(returnContextNode, transformer)) { + var returnValue = ts.getSynthesizedDeepClone(node); + if (hasContinuation) { + returnValue = ts.factory.createAwaitExpression(returnValue); + } + return [ts.factory.createReturnStatement(returnValue)]; } - return createVariableOrAssignmentOrExpressionStatement(prevArgName, ts.factory.createAwaitExpression(node), /*typeAnnotation*/ undefined); + return createVariableOrAssignmentOrExpressionStatement(continuationArgName, ts.factory.createAwaitExpression(node), /*typeAnnotation*/ undefined); } function createVariableOrAssignmentOrExpressionStatement(variableName, rightHandSide, typeAnnotation) { if (!variableName || isEmptyBindingName(variableName)) { @@ -144676,12 +147663,12 @@ var ts; } if (isSynthIdentifier(variableName) && variableName.hasBeenDeclared) { // if the variable has already been declared, we don't need "let" or "const" - return [ts.factory.createExpressionStatement(ts.factory.createAssignment(ts.getSynthesizedDeepClone(variableName.identifier), rightHandSide))]; + return [ts.factory.createExpressionStatement(ts.factory.createAssignment(ts.getSynthesizedDeepClone(referenceSynthIdentifier(variableName)), rightHandSide))]; } return [ ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ - ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(getNode(variableName)), + ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingName(variableName)), /*exclamationToken*/ undefined, typeAnnotation, rightHandSide) ], 2 /* Const */)) ]; @@ -144696,21 +147683,26 @@ var ts; return [ts.factory.createReturnStatement(expressionToReturn)]; } // should be kept up to date with isFixablePromiseArgument in suggestionDiagnostics.ts - function getTransformationBody(func, prevArgName, argName, parent, transformer) { - var _a, _b, _c, _d, _e; + /** + * @param hasContinuation Whether another `then`, `catch`, or `finally` continuation follows the continuation to which this callback belongs. + * @param continuationArgName The argument name for the continuation that follows this call. + * @param inputArgName The argument name provided to this call + */ + function transformCallbackArgument(func, hasContinuation, continuationArgName, inputArgName, parent, transformer) { + var _a; switch (func.kind) { case 104 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: case 79 /* Identifier */: // identifier includes undefined - if (!argName) { + if (!inputArgName) { // undefined was argument passed to promise handler break; } - var synthCall = ts.factory.createCallExpression(ts.getSynthesizedDeepClone(func), /*typeArguments*/ undefined, isSynthIdentifier(argName) ? [argName.identifier] : []); + var synthCall = ts.factory.createCallExpression(ts.getSynthesizedDeepClone(func), /*typeArguments*/ undefined, isSynthIdentifier(inputArgName) ? [referenceSynthIdentifier(inputArgName)] : []); if (shouldReturn(parent, transformer)) { - return maybeAnnotateAndReturn(synthCall, (_a = parent.typeArguments) === null || _a === void 0 ? void 0 : _a[0]); + return maybeAnnotateAndReturn(synthCall, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); } var type = transformer.checker.getTypeAtLocation(func); var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */); @@ -144719,56 +147711,96 @@ var ts; return silentFail(); } var returnType = callSignatures[0].getReturnType(); - var varDeclOrAssignment = createVariableOrAssignmentOrExpressionStatement(prevArgName, ts.factory.createAwaitExpression(synthCall), (_b = parent.typeArguments) === null || _b === void 0 ? void 0 : _b[0]); - if (prevArgName) { - prevArgName.types.push(returnType); + var varDeclOrAssignment = createVariableOrAssignmentOrExpressionStatement(continuationArgName, ts.factory.createAwaitExpression(synthCall), getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); + if (continuationArgName) { + continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType); } return varDeclOrAssignment; - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: { + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: { var funcBody = func.body; - var returnType_1 = (_c = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _c === void 0 ? void 0 : _c.getReturnType(); + var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType(); // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { var refactoredStmts = []; var seenReturnStatement = false; - for (var _i = 0, _f = funcBody.statements; _i < _f.length; _i++) { - var statement = _f[_i]; + for (var _i = 0, _b = funcBody.statements; _i < _b.length; _i++) { + var statement = _b[_i]; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; if (ts.isReturnStatementWithFixablePromiseHandler(statement, transformer.checker)) { - refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); + refactoredStmts = refactoredStmts.concat(transformReturnStatementWithFixablePromiseHandler(transformer, statement, hasContinuation, continuationArgName)); } else { var possiblyAwaitedRightHandSide = returnType_1 && statement.expression ? getPossiblyAwaitedRightHandSide(transformer.checker, returnType_1, statement.expression) : statement.expression; - refactoredStmts.push.apply(refactoredStmts, maybeAnnotateAndReturn(possiblyAwaitedRightHandSide, (_d = parent.typeArguments) === null || _d === void 0 ? void 0 : _d[0])); + refactoredStmts.push.apply(refactoredStmts, maybeAnnotateAndReturn(possiblyAwaitedRightHandSide, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker))); } } + else if (hasContinuation && ts.forEachReturnStatement(statement, ts.returnTrue)) { + // If there is a nested `return` in a callback that has a trailing continuation, we don't transform it as the resulting complexity is too great. For example: + // + // source | result + // -------------------------------------| --------------------------------------- + // function f(): Promise { | async function f9(): Promise { + // return foo().then(() => { | await foo(); + // if (Math.random()) { | if (Math.random()) { + // return 1; | return 1; // incorrect early return + // } | } + // return 2; | return 2; // incorrect early return + // }).then(a => { | const a = undefined; + // return a + 1; | return a + 1; + // }); | } + // } | + // + // However, branching returns in the outermost continuation are acceptable as no other continuation follows it: + // + // source | result + //--------------------------------------|--------------------------------------- + // function f() { | async function f() { + // return foo().then(res => { | const res = await foo(); + // if (res.ok) { | if (res.ok) { + // return 1; | return 1; + // } | } + // else { | else { + // if (res.buffer.length > 5) { | if (res.buffer.length > 5) { + // return 2; | return 2; + // } | } + // else { | else { + // return 3; | return 3; + // } | } + // } | } + // }); | } + // } | + // + // We may improve this in the future, but for now the heuristics are too complex + return silentFail(); + } else { refactoredStmts.push(statement); } } return shouldReturn(parent, transformer) ? refactoredStmts.map(function (s) { return ts.getSynthesizedDeepClone(s); }) - : removeReturns(refactoredStmts, prevArgName, transformer, seenReturnStatement); + : removeReturns(refactoredStmts, continuationArgName, transformer, seenReturnStatement); } else { - var innerRetStmts = ts.isFixablePromiseHandler(funcBody, transformer.checker) ? [ts.factory.createReturnStatement(funcBody)] : ts.emptyArray; - var innerCbBody = getInnerTransformationBody(transformer, innerRetStmts, prevArgName); - if (innerCbBody.length > 0) { - return innerCbBody; + var inlinedStatements = ts.isFixablePromiseHandler(funcBody, transformer.checker) ? + transformReturnStatementWithFixablePromiseHandler(transformer, ts.factory.createReturnStatement(funcBody), hasContinuation, continuationArgName) : + ts.emptyArray; + if (inlinedStatements.length > 0) { + return inlinedStatements; } if (returnType_1) { var possiblyAwaitedRightHandSide = getPossiblyAwaitedRightHandSide(transformer.checker, returnType_1, funcBody); if (!shouldReturn(parent, transformer)) { - var transformedStatement = createVariableOrAssignmentOrExpressionStatement(prevArgName, possiblyAwaitedRightHandSide, /*typeAnnotation*/ undefined); - if (prevArgName) { - prevArgName.types.push(returnType_1); + var transformedStatement = createVariableOrAssignmentOrExpressionStatement(continuationArgName, possiblyAwaitedRightHandSide, /*typeAnnotation*/ undefined); + if (continuationArgName) { + continuationArgName.types.push(transformer.checker.getAwaitedType(returnType_1) || returnType_1); } return transformedStatement; } else { - return maybeAnnotateAndReturn(possiblyAwaitedRightHandSide, (_e = parent.typeArguments) === null || _e === void 0 ? void 0 : _e[0]); + return maybeAnnotateAndReturn(possiblyAwaitedRightHandSide, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); } } else { @@ -144800,8 +147832,11 @@ var ts; if (prevArgName === undefined) { ret.push(ts.factory.createExpressionStatement(possiblyAwaitedExpression)); } + else if (isSynthIdentifier(prevArgName) && prevArgName.hasBeenDeclared) { + ret.push(ts.factory.createExpressionStatement(ts.factory.createAssignment(referenceSynthIdentifier(prevArgName), possiblyAwaitedExpression))); + } else { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(getNode(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); } } } @@ -144811,27 +147846,28 @@ var ts; } // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables if (!seenReturnStatement && prevArgName !== undefined) { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(getNode(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */)))); } return ret; } - function getInnerTransformationBody(transformer, innerRetStmts, prevArgName) { + /** + * @param hasContinuation Whether another `then`, `catch`, or `finally` continuation follows the continuation to which this statement belongs. + * @param continuationArgName The argument name for the continuation that follows this call. + */ + function transformReturnStatementWithFixablePromiseHandler(transformer, innerRetStmt, hasContinuation, continuationArgName) { var innerCbBody = []; - for (var _i = 0, innerRetStmts_1 = innerRetStmts; _i < innerRetStmts_1.length; _i++) { - var stmt = innerRetStmts_1[_i]; - ts.forEachChild(stmt, function visit(node) { - if (ts.isCallExpression(node)) { - var temp = transformExpression(node, transformer, prevArgName); - innerCbBody = innerCbBody.concat(temp); - if (innerCbBody.length > 0) { - return; - } - } - else if (!ts.isFunctionLike(node)) { - ts.forEachChild(node, visit); + ts.forEachChild(innerRetStmt, function visit(node) { + if (ts.isCallExpression(node)) { + var temp = transformExpression(node, node, transformer, hasContinuation, continuationArgName); + innerCbBody = innerCbBody.concat(temp); + if (innerCbBody.length > 0) { + return; } - }); - } + } + else if (!ts.isFunctionLike(node)) { + ts.forEachChild(node, visit); + } + }); return innerCbBody; } function getArgBindingName(funcNode, transformer) { @@ -144890,18 +147926,33 @@ var ts; } return ts.every(bindingName.elements, isEmptyBindingName); } - function getNode(bindingName) { - return isSynthIdentifier(bindingName) ? bindingName.identifier : bindingName.bindingPattern; - } function createSynthIdentifier(identifier, types) { if (types === void 0) { types = []; } - return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false }; + return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; } function createSynthBindingPattern(bindingPattern, elements, types) { if (elements === void 0) { elements = ts.emptyArray; } if (types === void 0) { types = []; } return { kind: 1 /* BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; } + function referenceSynthIdentifier(synthId) { + synthId.hasBeenReferenced = true; + return synthId.identifier; + } + function declareSynthBindingName(synthName) { + return isSynthIdentifier(synthName) ? declareSynthIdentifier(synthName) : declareSynthBindingPattern(synthName); + } + function declareSynthBindingPattern(synthPattern) { + for (var _i = 0, _a = synthPattern.elements; _i < _a.length; _i++) { + var element = _a[_i]; + declareSynthBindingName(element); + } + return synthPattern.bindingPattern; + } + function declareSynthIdentifier(synthId) { + synthId.hasBeenDeclared = true; + return synthId.identifier; + } function isSynthIdentifier(bindingName) { return bindingName.kind === 0 /* Identifier */; } @@ -144919,11 +147970,11 @@ var ts; var codefix; (function (codefix) { codefix.registerCodeFix({ - errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module.code], + errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module.code], getCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { - var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target, ts.getQuotePreference(sourceFile, preferences)); + var moduleExportsChangedToDefault = convertFileToEsModule(sourceFile, program.getTypeChecker(), changes, ts.getEmitScriptTarget(program.getCompilerOptions()), ts.getQuotePreference(sourceFile, preferences)); if (moduleExportsChangedToDefault) { for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var importingFile = _a[_i]; @@ -144932,22 +147983,22 @@ var ts; } }); // No support for fix-all since this applies to the whole file at once anyway. - return [codefix.createCodeFixActionWithoutFixAll("convertToEs6Module", changes, ts.Diagnostics.Convert_to_ES6_module)]; + return [codefix.createCodeFixActionWithoutFixAll("convertToEsModule", changes, ts.Diagnostics.Convert_to_ES_module)]; }, }); function fixImportOfModuleExports(importingFile, exportingFile, changes, quotePreference) { for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) { var moduleSpecifier = _a[_i]; - var imported = ts.getResolvedModule(importingFile, moduleSpecifier.text); + var imported = ts.getResolvedModule(importingFile, moduleSpecifier.text, ts.getModeForUsageLocation(importingFile, moduleSpecifier)); if (!imported || imported.resolvedFileName !== exportingFile.fileName) { continue; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 206 /* CallExpression */: + case 207 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -144956,7 +148007,7 @@ var ts; } } /** @returns Whether we converted a `module.exports =` to a default export. */ - function convertFileToEs6Module(sourceFile, checker, changes, target, quotePreference) { + function convertFileToEsModule(sourceFile, checker, changes, target, quotePreference) { var identifiers = { original: collectFreeIdentifiers(sourceFile), additional: new ts.Set() }; var exports = collectExportRenames(sourceFile, checker, identifiers); convertExportsAccesses(sourceFile, exports, changes); @@ -145014,20 +148065,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 236 /* ExpressionStatement */: { + case 237 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 206 /* CallExpression */: { + case 207 /* 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 219 /* BinaryExpression */: { + case 220 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } @@ -145076,8 +148127,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 199 /* ObjectBindingPattern */: - case 200 /* ArrayBindingPattern */: { + case 200 /* ObjectBindingPattern */: + case 201 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -145089,7 +148140,7 @@ var ts; // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: - return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { @@ -145128,16 +148179,16 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 292 /* ShorthandPropertyAssignment */: - case 293 /* SpreadAssignment */: + case 295 /* ShorthandPropertyAssignment */: + case 296 /* SpreadAssignment */: return undefined; - case 291 /* PropertyAssignment */: + case 294 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 167 /* MethodDeclaration */: + case 168 /* 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); @@ -145156,7 +148207,7 @@ var ts; */ var newNodes = [ makeConst(/*modifiers*/ undefined, rename, assignment.right), - makeExportDeclaration([ts.factory.createExportSpecifier(rename, text)]), + makeExportDeclaration([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, rename, text)]), ]; changes.replaceNodeWithNodes(sourceFile, assignment.parent, newNodes); } @@ -145178,7 +148229,7 @@ var ts; return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); } function reExportDefault(moduleSpecifier) { - return makeExportDeclaration([ts.factory.createExportSpecifier(/*propertyName*/ undefined, "default")], moduleSpecifier); + return makeExportDeclaration([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, "default")], moduleSpecifier); } function convertExportsPropertyAssignment(_a, sourceFile, changes) { var left = _a.left, right = _a.right, parent = _a.parent; @@ -145201,7 +148252,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; switch (exported.kind) { - case 211 /* FunctionExpression */: { + case 212 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -145209,10 +148260,10 @@ var ts; } } // falls through - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 224 /* ClassExpression */: + case 225 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -145232,7 +148283,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 === 204 /* PropertyAccessExpression */) { + if (original.kind === 205 /* 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); @@ -145247,7 +148298,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 199 /* ObjectBindingPattern */: { + case 200 /* 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 @@ -145260,7 +148311,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 200 /* ArrayBindingPattern */: { + case 201 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -145274,7 +148325,7 @@ var ts; 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); + return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind); } } /** @@ -145320,7 +148371,7 @@ var ts; } var namedBindings = namedBindingsNames.size === 0 ? undefined : ts.arrayFrom(ts.mapIterator(namedBindingsNames.entries(), function (_a) { var propertyName = _a[0], idName = _a[1]; - return ts.factory.createImportSpecifier(propertyName === idName ? undefined : ts.factory.createIdentifier(propertyName), ts.factory.createIdentifier(idName)); + return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName === idName ? undefined : ts.factory.createIdentifier(propertyName), ts.factory.createIdentifier(idName)); })); if (!namedBindings) { // If it was unused, ensure that we at least import *something*. @@ -145353,11 +148404,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: return parent.name !== node; - case 201 /* BindingElement */: + case 202 /* BindingElement */: return parent.propertyName !== node; - case 268 /* ImportSpecifier */: + case 269 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -145378,7 +148429,7 @@ var ts; : ts.makeImport(/*name*/ undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier, quotePreference); } function makeImportSpecifier(propertyName, name) { - return ts.factory.createImportSpecifier(propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name)); + return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name)); } function makeConst(modifiers, name, init) { return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* Const */)); @@ -145471,15 +148522,17 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 150 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 151 /* TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.decorators, exportDeclaration.modifiers, - /*isTypeOnly*/ false, ts.factory.updateNamedExports(exportClause, ts.filter(exportClause.elements, function (e) { return !ts.contains(typeExportSpecifiers, e); })), exportDeclaration.moduleSpecifier); + /*isTypeOnly*/ false, ts.factory.updateNamedExports(exportClause, ts.filter(exportClause.elements, function (e) { return !ts.contains(typeExportSpecifiers, e); })), exportDeclaration.moduleSpecifier, + /*assertClause*/ undefined); var typeExportDeclaration = ts.factory.createExportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*isTypeOnly*/ true, ts.factory.createNamedExports(typeExportSpecifiers), exportDeclaration.moduleSpecifier); + /*isTypeOnly*/ true, ts.factory.createNamedExports(typeExportSpecifiers), exportDeclaration.moduleSpecifier, + /*assertClause*/ undefined); changes.replaceNode(context.sourceFile, exportDeclaration, valueExportDeclaration, { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Exclude @@ -145543,7 +148596,8 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( /*isTypeOnly*/ true, importClause.name, - /*namedBindings*/ undefined), importDeclaration.moduleSpecifier)); + /*namedBindings*/ undefined), importDeclaration.moduleSpecifier, + /*assertClause*/ undefined)); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -145591,7 +148645,11 @@ var ts; } function doChange(changes, sourceFile, _a) { var container = _a.container, typeNode = _a.typeNode, constraint = _a.constraint, name = _a.name; - changes.replaceNode(sourceFile, container, ts.factory.createMappedTypeNode(/*readonlyToken*/ undefined, ts.factory.createTypeParameterDeclaration(name, ts.factory.createTypeReferenceNode(constraint)), /*nameType*/ undefined, /*questionToken*/ undefined, typeNode)); + changes.replaceNode(sourceFile, container, ts.factory.createMappedTypeNode( + /*readonlyToken*/ undefined, ts.factory.createTypeParameterDeclaration(name, ts.factory.createTypeReferenceNode(constraint)), + /*nameType*/ undefined, + /*questionToken*/ undefined, typeNode, + /*members*/ undefined)); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -145700,13 +148758,13 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span; + var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span, program = context.program; var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true); if (!info) return undefined; var fixes = info.fixes, symbolName = info.symbolName; var quotePreference = ts.getQuotePreference(sourceFile, preferences); - return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference); }); + return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, program.getCompilerOptions()); }); }, fixIds: [importFixId], getAllCodeActions: function (context) { @@ -145725,77 +148783,77 @@ var ts; // Namespace fixes don't conflict, so just build a list. var addToNamespace = []; var importType = []; - // Keys are import clause node IDs. + /** Keys are import clause node IDs. */ var addToExisting = new ts.Map(); + /** Use `getNewImportEntry` for access */ var newImports = new ts.Map(); - return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes }; + return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes, hasFixes: hasFixes }; function addImportFromDiagnostic(diagnostic, context) { var info = getFixesInfo(context, diagnostic.code, diagnostic.start, useAutoImportProvider); if (!info || !info.fixes.length) return; addImport(info); } - function addImportFromExportedSymbol(exportedSymbol, usageIsTypeOnly) { + function addImportFromExportedSymbol(exportedSymbol, isValidTypeOnlyUseSite) { var moduleSymbol = ts.Debug.checkDefined(exportedSymbol.parent); 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, 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); + var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences); if (fix) { addImport({ fixes: [fix], symbolName: symbolName }); } } function addImport(info) { + var _a, _b; var fixes = info.fixes, symbolName = info.symbolName; var fix = ts.first(fixes); switch (fix.kind) { case 0 /* UseNamespace */: addToNamespace.push(fix); break; - case 1 /* ImportType */: + case 1 /* JsdocTypeImport */: importType.push(fix); break; case 2 /* AddToExisting */: { - var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, canUseTypeOnlyImport = fix.canUseTypeOnlyImport; + var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly; var key = String(ts.getNodeId(importClauseOrBindingPattern)); var entry = addToExisting.get(key); if (!entry) { - addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: [], canUseTypeOnlyImport: canUseTypeOnlyImport }); + addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: new ts.Map() }); } if (importKind === 0 /* Named */) { - ts.pushIfUnique(entry.namedImports, symbolName); + var prevValue = entry === null || entry === void 0 ? void 0 : entry.namedImports.get(symbolName); + entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); - entry.defaultImport = symbolName; + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); + entry.defaultImport = { + name: symbolName, + addAsTypeOnly: reduceAddAsTypeOnlyValues((_a = entry.defaultImport) === null || _a === void 0 ? void 0 : _a.addAsTypeOnly, addAsTypeOnly), + }; } break; } case 3 /* AddNew */: { - var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, typeOnly = fix.typeOnly; - var entry = newImports.get(moduleSpecifier); - if (!entry) { - newImports.set(moduleSpecifier, entry = { namedImports: [], namespaceLikeImport: undefined, typeOnly: typeOnly, useRequire: useRequire }); - } - else { - // An import clause can only be type-only if every import fix contributing to it can be type-only. - entry.typeOnly = entry.typeOnly && typeOnly; - } + var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, addAsTypeOnly = fix.addAsTypeOnly; + var entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly); + ts.Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module"); switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); - entry.defaultImport = symbolName; + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add new) Default import should be missing or match symbolName"); + entry.defaultImport = { name: symbolName, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) === null || _b === void 0 ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) }; break; case 0 /* Named */: - ts.pushIfUnique(entry.namedImports || (entry.namedImports = []), symbolName); + var prevValue = (entry.namedImports || (entry.namedImports = new ts.Map())).get(symbolName); + entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); break; case 3 /* CommonJS */: case 2 /* Namespace */: ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); - entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; + entry.namespaceLikeImport = { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly }; break; } break; @@ -145803,6 +148861,50 @@ var ts; default: ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } + function reduceAddAsTypeOnlyValues(prevValue, newValue) { + // `NotAllowed` overrides `Required` because one addition of a new import might be required to be type-only + // because of `--importsNotUsedAsValues=error`, but if a second addition of the same import is `NotAllowed` + // to be type-only, the reason the first one was `Required` - the unused runtime dependency - is now moot. + // Alternatively, if one addition is `Required` because it has no value meaning under `--preserveValueImports` + // and `--isolatedModules`, it should be impossible for another addition to be `NotAllowed` since that would + // mean a type is being referenced in a value location. + return Math.max(prevValue !== null && prevValue !== void 0 ? prevValue : 0, newValue); + } + function getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly) { + // A default import that requires type-only makes the whole import type-only. + // (We could add `default` as a named import, but that style seems undesirable.) + // Under `--preserveValueImports` and `--importsNotUsedAsValues=error`, if a + // module default-exports a type but named-exports some values (weird), you would + // have to use a type-only default import and non-type-only named imports. These + // require two separate import declarations, so we build this into the map key. + var typeOnlyKey = newImportsKey(moduleSpecifier, /*topLevelTypeOnly*/ true); + var nonTypeOnlyKey = newImportsKey(moduleSpecifier, /*topLevelTypeOnly*/ false); + var typeOnlyEntry = newImports.get(typeOnlyKey); + var nonTypeOnlyEntry = newImports.get(nonTypeOnlyKey); + var newEntry = { + defaultImport: undefined, + namedImports: undefined, + namespaceLikeImport: undefined, + useRequire: useRequire + }; + if (importKind === 1 /* Default */ && addAsTypeOnly === 2 /* Required */) { + if (typeOnlyEntry) + return typeOnlyEntry; + newImports.set(typeOnlyKey, newEntry); + return newEntry; + } + if (addAsTypeOnly === 1 /* Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { + return (typeOnlyEntry || nonTypeOnlyEntry); + } + if (nonTypeOnlyEntry) { + return nonTypeOnlyEntry; + } + newImports.set(nonTypeOnlyKey, newEntry); + return newEntry; + } + function newImportsKey(moduleSpecifier, topLevelTypeOnly) { + return (topLevelTypeOnly ? 1 : 0) + "|" + moduleSpecifier; + } } function writeFixes(changeTracker) { var quotePreference = ts.getQuotePreference(sourceFile, preferences); @@ -145815,42 +148917,66 @@ var ts; addImportType(changeTracker, sourceFile, fix, quotePreference); } addToExisting.forEach(function (_a) { - var importClauseOrBindingPattern = _a.importClauseOrBindingPattern, defaultImport = _a.defaultImport, namedImports = _a.namedImports, canUseTypeOnlyImport = _a.canUseTypeOnlyImport; - doAddExistingFix(changeTracker, sourceFile, importClauseOrBindingPattern, defaultImport, namedImports, canUseTypeOnlyImport); + var importClauseOrBindingPattern = _a.importClauseOrBindingPattern, defaultImport = _a.defaultImport, namedImports = _a.namedImports; + doAddExistingFix(changeTracker, sourceFile, importClauseOrBindingPattern, defaultImport, ts.arrayFrom(namedImports.entries(), function (_a) { + var name = _a[0], addAsTypeOnly = _a[1]; + return ({ addAsTypeOnly: addAsTypeOnly, name: name }); + }), compilerOptions); }); var newDeclarations; - newImports.forEach(function (_a, moduleSpecifier) { - var useRequire = _a.useRequire, imports = __rest(_a, ["useRequire"]); + newImports.forEach(function (_a, key) { + var useRequire = _a.useRequire, defaultImport = _a.defaultImport, namedImports = _a.namedImports, namespaceLikeImport = _a.namespaceLikeImport; + var moduleSpecifier = key.slice(2); // From `${0 | 1}|${moduleSpecifier}` format var getDeclarations = useRequire ? getNewRequires : getNewImports; - newDeclarations = ts.combine(newDeclarations, getDeclarations(moduleSpecifier, quotePreference, imports)); + var declarations = getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports && ts.arrayFrom(namedImports.entries(), function (_a) { + var name = _a[0], addAsTypeOnly = _a[1]; + return ({ addAsTypeOnly: addAsTypeOnly, name: name }); + }), namespaceLikeImport); + newDeclarations = ts.combine(newDeclarations, declarations); }); if (newDeclarations) { ts.insertImports(changeTracker, sourceFile, newDeclarations, /*blankLineBetween*/ true); } } + function hasFixes() { + return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0; + } } // Sorted with the preferred fix coming first. var ImportFixKind; (function (ImportFixKind) { ImportFixKind[ImportFixKind["UseNamespace"] = 0] = "UseNamespace"; - ImportFixKind[ImportFixKind["ImportType"] = 1] = "ImportType"; + ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport"; ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting"; ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew"; })(ImportFixKind || (ImportFixKind = {})); - function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { + // These should not be combined as bitflags, but are given powers of 2 values to + // easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum. + // They're also ordered in terms of increasing priority for a fix-all scenario (see + // `reduceAddAsTypeOnlyValues`). + var AddAsTypeOnly; + (function (AddAsTypeOnly) { + AddAsTypeOnly[AddAsTypeOnly["Allowed"] = 1] = "Allowed"; + AddAsTypeOnly[AddAsTypeOnly["Required"] = 2] = "Required"; + AddAsTypeOnly[AddAsTypeOnly["NotAllowed"] = 4] = "NotAllowed"; + })(AddAsTypeOnly || (AddAsTypeOnly = {})); + function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var compilerOptions = program.getCompilerOptions(); var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name)) - ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, program, host)] - : getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true); + ? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)] + : getAllReExportingModules(sourceFile, targetSymbol, 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 = 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))) }; + var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); + var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences)); + return { + moduleSpecifier: fix.moduleSpecifier, + codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences), compilerOptions)) + }; } codefix.getImportCompletionAction = getImportCompletionAction; - function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences) { + function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) { 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); + return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, host, preferences); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; @@ -145876,7 +149002,7 @@ var ts; } } } - function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) { + function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) { var result = []; var compilerOptions = program.getCompilerOptions(); var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { @@ -145889,12 +149015,12 @@ var ts; return; } 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)) { + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, 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)) { + if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, 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 }); } } @@ -145908,24 +149034,21 @@ var ts; function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, fromCacheOnly) { var _a = getNewImportFixes(program, importingFile, /*position*/ undefined, - /*preferTypeOnlyImport*/ false, + /*isValidTypeOnlyUseSite*/ 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 isTypeOnlyPosition(sourceFile, position) { - return ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - } function getImportFixes(exportInfos, symbolName, /** undefined only for missing JSX namespace */ - position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences) { + position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); }); var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); - var addToExisting = tryAddToExistingImport(existingImports, position !== undefined && isTypeOnlyPosition(sourceFile, position)); + var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions()); // 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); + var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences); return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), addImport, true); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { @@ -145956,11 +149079,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 264 /* ImportDeclaration */: + case 265 /* 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: @@ -145970,24 +149093,44 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return declaration.name.text; - case 264 /* ImportDeclaration */: + case 265 /* 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); } } - function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) { + function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, symbol, targetFlags, checker, compilerOptions) { + if (!isValidTypeOnlyUseSite) { + // Can't use a type-only import if the usage is an emitting position + return 4 /* NotAllowed */; + } + if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* Error */) { + // Not writing a (top-level) type-only import here would create an error because the runtime dependency is unnecessary + return 2 /* Required */; + } + if (compilerOptions.isolatedModules && compilerOptions.preserveValueImports && + (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { + // A type-only import is required for this symbol if under these settings if the symbol will + // be erased, which will happen if the target symbol is purely a type or if it was exported/imported + // as type-only already somewhere between this import and the target. + return 2 /* Required */; + } + return 1 /* Allowed */; + } + function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) { return ts.firstDefined(existingImports, function (_a) { - var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 263 /* ImportEqualsDeclaration */) + var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; + if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 264 /* ImportEqualsDeclaration */) { + // These kinds of imports are not combinable with anything return undefined; - 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 } + } + if (declaration.kind === 253 /* VariableDeclaration */) { + return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 200 /* ObjectBindingPattern */ + ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } : undefined; } var importClause = declaration.importClause; @@ -145998,13 +149141,29 @@ 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 === 267 /* NamedImports */) - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, canUseTypeOnlyImport: canUseTypeOnlyImport } - : undefined; + // N.B. we don't have to figure out whether to use the main program checker + // or the AutoImportProvider checker because we're adding to an existing import; the existence of + // the import guarantees the symbol came from the main program. + var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ false, symbol, targetFlags, checker, compilerOptions); + if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one + addAsTypeOnly === 2 /* Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings + )) + return undefined; + if (importKind === 0 /* Named */ && + (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 267 /* NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import + ) + return undefined; + return { + kind: 2 /* AddToExisting */, + importClauseOrBindingPattern: importClause, + importKind: importKind, + moduleSpecifier: declaration.moduleSpecifier.text, + addAsTypeOnly: addAsTypeOnly, + }; }); } function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { - var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags; + var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol; // Can't use an es6 import for a type in JS. if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile)) return ts.emptyArray; @@ -146012,10 +149171,10 @@ var ts; return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); if (ts.isRequireVariableDeclaration(i.parent)) { - return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind } : undefined; + return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } - if (i.kind === 264 /* ImportDeclaration */ || i.kind === 263 /* ImportEqualsDeclaration */) { - return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; + if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) { + return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined; } }); } @@ -146047,44 +149206,50 @@ var ts; // 5. Literally nothing to go on return true; } - function getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences, fromCacheOnly) { + function getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, moduleSymbols, host, preferences, fromCacheOnly) { var isJs = ts.isSourceFileJS(sourceFile); var compilerOptions = program.getCompilerOptions(); var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); - var checker = program.getTypeChecker(); + var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : 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); }; + : function (moduleSymbol, checker) { 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; + var checker = getChecker(exportInfo.isFromPackageJson); + var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; + var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */); + var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); 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.targetFlags & 111551 /* Value */) && isJs && position !== undefined - ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo } + return !importedSymbolHasValueMeaning && isJs && position !== undefined + ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, - typeOnly: preferTypeOnlyImport, + addAsTypeOnly: addAsTypeOnly, 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).fixes; + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences) { + var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); }); + return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes; } - function newImportInfoFromExistingSpecifier(_a, preferTypeOnlyImport, useRequire) { - var declaration = _a.declaration, importKind = _a.importKind; + function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) { + var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); - return moduleSpecifier - ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } - : undefined; + if (moduleSpecifier) { + var addAsTypeOnly = useRequire + ? 4 /* NotAllowed */ + : getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, symbol, targetFlags, checker, compilerOptions); + return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; + } } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos); @@ -146106,12 +149271,14 @@ var ts; } var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier; return fixes.reduce(function (best, fix) { + // Takes true branch of conditional if `fix` is better than `best` return compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best; }); } + /** @returns `Comparison.LessThan` if `a` is better than `b`. */ 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)) + return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); } @@ -146134,7 +149301,7 @@ var ts; var symbolName = umdSymbol.name; 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); + var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } function getUmdSymbol(token, checker) { @@ -146180,10 +149347,14 @@ var ts; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: + case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.None: // Fall back to the `import * as ns` style import. return 2 /* Namespace */; + case ts.ModuleKind.Node12: + case ts.ModuleKind.NodeNext: + return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */; default: return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } @@ -146195,18 +149366,21 @@ var ts; var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, so we don't expect it here 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 isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken); var useRequire = shouldUseRequire(sourceFile, program); 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); + return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } + function jsxModeNeedsExplicitImport(jsx) { + return jsx === 2 /* React */ || jsx === 3 /* ReactNative */; + } function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; - if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx !== 4 /* ReactJSX */ && compilerOptions.jsx !== 5 /* ReactJSXDev */) { + if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) { var jsxNamespace = checker.getJsxNamespace(sourceFile); if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) { return jsxNamespace; @@ -146238,7 +149412,7 @@ var ts; cancellationToken.throwIfCancellationRequested(); var compilerOptions = program.getCompilerOptions(); var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); - if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson); } // check exports with the same name @@ -146278,63 +149452,81 @@ var ts; // allowSyntheticDefaultImports/esModuleInterop is enabled. return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; } - function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference) { + function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, compilerOptions) { var diag; var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { - diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference); + diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference, compilerOptions); }); return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports); } - function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference) { + function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference, compilerOptions) { switch (fix.kind) { case 0 /* UseNamespace */: addNamespaceQualifier(changes, sourceFile, fix); return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; - case 1 /* ImportType */: + case 1 /* JsdocTypeImport */: addImportType(changes, sourceFile, fix, quotePreference); return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; case 2 /* AddToExisting */: { - var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, canUseTypeOnlyImport = fix.canUseTypeOnlyImport, moduleSpecifier = fix.moduleSpecifier; - doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray, canUseTypeOnlyImport); + var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier; + doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); - return [importKind === 1 /* Default */ ? ts.Diagnostics.Add_default_import_0_to_existing_import_declaration_from_1 : ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; // you too! + return [ + importKind === 1 /* Default */ ? ts.Diagnostics.Add_default_import_0_to_existing_import_declaration_from_1 : ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, + symbolName, + moduleSpecifierWithoutQuotes + ]; // you too! } case 3 /* AddNew */: { - var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, typeOnly = fix.typeOnly, useRequire = fix.useRequire; + var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire; var getDeclarations = useRequire ? getNewRequires : getNewImports; - var importsCollection = importKind === 1 /* Default */ ? { defaultImport: symbolName, typeOnly: typeOnly } : - importKind === 0 /* Named */ ? { namedImports: [symbolName], typeOnly: typeOnly } : - { namespaceLikeImport: { importKind: importKind, name: symbolName }, typeOnly: typeOnly }; - ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, importsCollection), /*blankLineBetween*/ true); + var defaultImport = importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; + var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true); return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } - function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) { - if (clause.kind === 199 /* ObjectBindingPattern */) { + function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) { + var _a; + if (clause.kind === 200 /* ObjectBindingPattern */) { if (defaultImport) { - addElementToBindingPattern(clause, defaultImport, "default"); + addElementToBindingPattern(clause, defaultImport.name, "default"); } for (var _i = 0, namedImports_1 = namedImports; _i < namedImports_1.length; _i++) { var specifier = namedImports_1[_i]; - addElementToBindingPattern(clause, specifier, /*propertyName*/ undefined); + addElementToBindingPattern(clause, specifier.name, /*propertyName*/ undefined); } return; } - var convertTypeOnlyToRegular = !canUseTypeOnlyImport && clause.isTypeOnly; + var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */; }); + var existingSpecifiers = clause.namedBindings && ((_a = ts.tryCast(clause.namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements); + // If we are promoting from a type-only import and `--isolatedModules` and `--preserveValueImports` + // are enabled, we need to make every existing import specifier type-only. It may be possible that + // some of them don't strictly need to be marked type-only (if they have a value meaning and are + // never used in an emitting position). These are allowed to be imported without being type-only, + // but the user has clearly already signified that they don't need them to be present at runtime + // by placing them in a type-only import. So, just mark each specifier as type-only. + var convertExistingToTypeOnly = promoteFromTypeOnly && compilerOptions.preserveValueImports && compilerOptions.isolatedModules; if (defaultImport) { ts.Debug.assert(!clause.name, "Cannot add a default import to an import clause that already has one"); - changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.factory.createIdentifier(defaultImport), { suffix: ", " }); + changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.factory.createIdentifier(defaultImport.name), { suffix: ", " }); } if (namedImports.length) { - var existingSpecifiers = clause.namedBindings && ts.cast(clause.namedBindings, ts.isNamedImports).elements; - var newSpecifiers = ts.stableSort(namedImports.map(function (name) { return ts.factory.createImportSpecifier(/*propertyName*/ undefined, ts.factory.createIdentifier(name)); }), ts.OrganizeImports.compareImportOrExportSpecifiers); + var newSpecifiers = ts.stableSort(namedImports.map(function (namedImport) { return ts.factory.createImportSpecifier((!clause.isTypeOnly || promoteFromTypeOnly) && needsTypeOnly(namedImport), + /*propertyName*/ undefined, ts.factory.createIdentifier(namedImport.name)); }), ts.OrganizeImports.compareImportOrExportSpecifiers); if ((existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) && ts.OrganizeImports.importSpecifiersAreSorted(existingSpecifiers)) { - for (var _a = 0, newSpecifiers_1 = newSpecifiers; _a < newSpecifiers_1.length; _a++) { - var spec = newSpecifiers_1[_a]; - var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec); + for (var _b = 0, newSpecifiers_1 = newSpecifiers; _b < newSpecifiers_1.length; _b++) { + var spec = newSpecifiers_1[_b]; + // Organize imports puts type-only import specifiers last, so if we're + // adding a non-type-only specifier and converting all the other ones to + // type-only, there's no need to ask for the insertion index - it's 0. + var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly + ? 0 + : ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec); var prevSpecifier = clause.namedBindings.elements[insertionIndex - 1]; if (prevSpecifier) { changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec); @@ -146345,8 +149537,8 @@ var ts; } } else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) { - for (var _b = 0, newSpecifiers_2 = newSpecifiers; _b < newSpecifiers_2.length; _b++) { - var spec = newSpecifiers_2[_b]; + for (var _c = 0, newSpecifiers_2 = newSpecifiers; _c < newSpecifiers_2.length; _c++) { + var spec = newSpecifiers_2[_c]; changes.insertNodeInListAfter(sourceFile, ts.last(existingSpecifiers), spec, existingSpecifiers); } } @@ -146362,8 +149554,14 @@ var ts; } } } - if (convertTypeOnlyToRegular) { + if (promoteFromTypeOnly) { changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(clause, sourceFile)); + if (convertExistingToTypeOnly && existingSpecifiers) { + for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) { + var specifier = existingSpecifiers_1[_d]; + changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, specifier); + } + } } function addElementToBindingPattern(bindingPattern, name, propertyName) { var element = ts.factory.createBindingElement(/*dotDotDotToken*/ undefined, propertyName, name); @@ -146387,43 +149585,53 @@ var ts; var quote = ts.getQuoteFromPreference(quotePreference); return "import(" + quote + moduleSpecifier + quote + ")."; } - function getNewImports(moduleSpecifier, quotePreference, imports) { - var _a, _b; + function needsTypeOnly(_a) { + var addAsTypeOnly = _a.addAsTypeOnly; + return addAsTypeOnly === 2 /* Required */; + } + function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) { var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); var statements; - if (imports.defaultImport !== undefined || ((_a = imports.namedImports) === null || _a === void 0 ? void 0 : _a.length)) { - statements = ts.combine(statements, ts.makeImport(imports.defaultImport === undefined ? undefined : ts.factory.createIdentifier(imports.defaultImport), (_b = imports.namedImports) === null || _b === void 0 ? void 0 : _b.map(function (n) { return ts.factory.createImportSpecifier(/*propertyName*/ undefined, ts.factory.createIdentifier(n)); }), moduleSpecifier, quotePreference, imports.typeOnly)); + if (defaultImport !== undefined || (namedImports === null || namedImports === void 0 ? void 0 : namedImports.length)) { + var topLevelTypeOnly_1 = (!defaultImport || needsTypeOnly(defaultImport)) && ts.every(namedImports, needsTypeOnly); + statements = ts.combine(statements, ts.makeImport(defaultImport && ts.factory.createIdentifier(defaultImport.name), namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) { + var addAsTypeOnly = _a.addAsTypeOnly, name = _a.name; + return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* Required */, + /*propertyName*/ undefined, ts.factory.createIdentifier(name)); + }), moduleSpecifier, quotePreference, topLevelTypeOnly_1)); } - var namespaceLikeImport = imports.namespaceLikeImport, typeOnly = imports.typeOnly; if (namespaceLikeImport) { var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ ? ts.factory.createImportEqualsDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, typeOnly, ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier)) + /*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier)) : ts.factory.createImportDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.createImportClause(typeOnly, - /*name*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier); + /*modifiers*/ undefined, ts.factory.createImportClause(needsTypeOnly(namespaceLikeImport), + /*name*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier, + /*assertClause*/ undefined); statements = ts.combine(statements, declaration); } return ts.Debug.checkDefined(statements); } - function getNewRequires(moduleSpecifier, quotePreference, imports) { - var _a, _b; + function getNewRequires(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) { var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); var statements; // const { default: foo, bar, etc } = require('./mod'); - if (imports.defaultImport || ((_a = imports.namedImports) === null || _a === void 0 ? void 0 : _a.length)) { - var bindingElements = ((_b = imports.namedImports) === null || _b === void 0 ? void 0 : _b.map(function (name) { return ts.factory.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name); })) || []; - if (imports.defaultImport) { - bindingElements.unshift(ts.factory.createBindingElement(/*dotDotDotToken*/ undefined, "default", imports.defaultImport)); + if (defaultImport || (namedImports === null || namedImports === void 0 ? void 0 : namedImports.length)) { + var bindingElements = (namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) { + var name = _a.name; + return ts.factory.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name); + })) || []; + if (defaultImport) { + bindingElements.unshift(ts.factory.createBindingElement(/*dotDotDotToken*/ undefined, "default", defaultImport.name)); } var declaration = createConstEqualsRequireDeclaration(ts.factory.createObjectBindingPattern(bindingElements), quotedModuleSpecifier); statements = ts.combine(statements, declaration); } // const foo = require('./mod'); - if (imports.namespaceLikeImport) { - var declaration = createConstEqualsRequireDeclaration(imports.namespaceLikeImport.name, quotedModuleSpecifier); + if (namespaceLikeImport) { + var declaration = createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier); statements = ts.combine(statements, declaration); } return ts.Debug.checkDefined(statements); @@ -146557,23 +149765,23 @@ var ts; 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); + changeTracker.insertModifierAt(sourceFile, modifierPos, 158 /* 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 === 157 /* OverrideKeyword */; }); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 158 /* OverrideKeyword */; }); ts.Debug.assertIsDefined(overrideModifier); changeTracker.deleteModifier(sourceFile, overrideModifier); } function isClassElementLikeHasJSDoc(node) { switch (node.kind) { - case 169 /* Constructor */: - case 165 /* PropertyDeclaration */: - case 167 /* MethodDeclaration */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 170 /* Constructor */: + case 166 /* PropertyDeclaration */: + case 168 /* MethodDeclaration */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: return true; - case 162 /* Parameter */: + case 163 /* Parameter */: return ts.isParameterPropertyDeclaration(node, node.parent); default: return false; @@ -146704,7 +149912,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 195 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 196 /* NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -146713,11 +149921,11 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 183 /* OptionalType */ || unwrappedType.kind === 184 /* RestType */ || unwrappedType.kind === 189 /* ParenthesizedType */) { - if (unwrappedType.kind === 183 /* OptionalType */) { + while (unwrappedType.kind === 184 /* OptionalType */ || unwrappedType.kind === 185 /* RestType */ || unwrappedType.kind === 190 /* ParenthesizedType */) { + if (unwrappedType.kind === 184 /* OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 184 /* RestType */) { + else if (unwrappedType.kind === 185 /* RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; @@ -146741,10 +149949,12 @@ var ts; 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_namespace_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, + ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_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 @@ -146758,14 +149968,14 @@ var ts; if (!info) return undefined; var node = info.node, suggestedSymbol = info.suggestedSymbol; - var target = context.host.getCompilationSettings().target; + var target = ts.getEmitScriptTarget(context.host.getCompilationSettings()); var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, node, suggestedSymbol, target); }); return [codefix.createCodeFixAction("spelling", changes, [ts.Diagnostics.Change_spelling_to_0, ts.symbolName(suggestedSymbol)], fixId, ts.Diagnostics.Fix_all_detected_spelling_errors)]; }, fixIds: [fixId], getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { var info = getInfo(diag.file, diag.start, context, diag.code); - var target = context.host.getCompilationSettings().target; + var target = ts.getEmitScriptTarget(context.host.getCompilationSettings()); if (info) doChange(changes, context.sourceFile, info.node, info.suggestedSymbol, target); }); }, @@ -146791,6 +150001,10 @@ var ts; } suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { + var receiverType = checker.getTypeAtLocation(parent.right); + suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType); + } else if (ts.isQualifiedName(parent) && parent.right === node) { var symbol = checker.getSymbolAtLocation(parent.left); if (symbol && symbol.flags & 1536 /* Module */) { @@ -146858,7 +150072,7 @@ var ts; function getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration) { if (!importDeclaration || !ts.isStringLiteralLike(importDeclaration.moduleSpecifier)) return undefined; - var resolvedModule = ts.getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text); + var resolvedModule = ts.getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, importDeclaration.moduleSpecifier)); if (!resolvedModule) return undefined; return context.program.getSourceFile(resolvedModule.resolvedFileName); @@ -147026,19 +150240,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 252 /* VariableDeclaration */: - case 162 /* Parameter */: - case 201 /* BindingElement */: - case 165 /* PropertyDeclaration */: - case 291 /* PropertyAssignment */: + case 253 /* VariableDeclaration */: + case 163 /* Parameter */: + case 202 /* BindingElement */: + case 166 /* PropertyDeclaration */: + case 294 /* PropertyAssignment */: return declaration.initializer; - case 283 /* JsxAttribute */: + case 284 /* JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 292 /* ShorthandPropertyAssignment */: - case 164 /* PropertySignature */: - case 294 /* EnumMember */: - case 342 /* JSDocPropertyTag */: - case 335 /* JSDocParameterTag */: + case 295 /* ShorthandPropertyAssignment */: + case 165 /* PropertySignature */: + case 297 /* EnumMember */: + case 345 /* JSDocPropertyTag */: + case 338 /* JSDocParameterTag */: return undefined; } } @@ -147089,13 +150303,14 @@ var ts; ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2.code, ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2.code, ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more.code, + ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, ts.Diagnostics.Cannot_find_name_0.code ]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { var typeChecker = context.program.getTypeChecker(); - var info = getInfo(context.sourceFile, context.span.start, typeChecker, context.program); + var info = getInfo(context.sourceFile, context.span.start, context.errorCode, typeChecker, context.program); if (!info) { return undefined; } @@ -147125,7 +150340,7 @@ var ts; var typeDeclToMembers = new ts.Map(); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { codefix.eachDiagnostic(context, errorCodes, function (diag) { - var info = getInfo(diag.file, diag.start, checker, context.program); + var info = getInfo(diag.file, diag.start, diag.code, checker, context.program); if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } @@ -147153,7 +150368,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = codefix.getAllSupers(classDeclaration, checker); - var _loop_14 = function (info) { + var _loop_15 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -147180,7 +150395,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_14(info); + _loop_15(info); } }); })); @@ -147194,38 +150409,52 @@ var ts; InfoKind[InfoKind["ObjectLiteral"] = 3] = "ObjectLiteral"; InfoKind[InfoKind["JsxAttributes"] = 4] = "JsxAttributes"; })(InfoKind || (InfoKind = {})); - function getInfo(sourceFile, tokenPos, checker, program) { + function getInfo(sourceFile, tokenPos, errorCode, checker, program) { // The identifier of the missing property. eg: // this.missing = 1; // ^^^^^^^ var token = ts.getTokenAtPosition(sourceFile, tokenPos); - if (!ts.isIdentifier(token) && !ts.isPrivateIdentifier(token)) { - return undefined; - } var parent = token.parent; + if (errorCode === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) { + if (!(token.kind === 18 /* OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) + return undefined; + var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; }); + if (argIndex < 0) + return undefined; + var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* Call */)); + if (!(signature && signature.declaration && signature.parameters[argIndex])) + return undefined; + var param = signature.parameters[argIndex].valueDeclaration; + if (!(param && ts.isParameter(param) && ts.isIdentifier(param.name))) + return undefined; + var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getTypeAtLocation(param), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); + if (!ts.length(properties)) + return undefined; + return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, indentation: 0, parentDeclaration: parent }; + } + if (!ts.isMemberName(token)) + return undefined; 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.length(properties)) + return undefined; + return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, indentation: undefined, 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.length(attributes)) + return undefined; + 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 }; } - if (!ts.isPropertyAccessExpression(parent)) { + if (!ts.isPropertyAccessExpression(parent)) return undefined; - } var leftExpressionType = ts.skipConstraint(checker.getTypeAtLocation(parent.expression)); var symbol = leftExpressionType.symbol; - if (!symbol || !symbol.declarations) { + if (!symbol || !symbol.declarations) return undefined; - } 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(); @@ -147233,25 +150462,22 @@ var ts; 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 (sourceFile.commonJsModuleIndicator) + return undefined; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; } } var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); // Don't suggest adding private identifiers to anything other than a class. - if (!classDeclaration && ts.isPrivateIdentifier(token)) { + if (!classDeclaration && ts.isPrivateIdentifier(token)) return undefined; - } // Prefer to change the class instead of the interface if they are merged var classOrInterface = classDeclaration || ts.find(symbol.declarations, ts.isInterfaceDeclaration); if (classOrInterface && !isSourceFileFromLibrary(program, classOrInterface.getSourceFile())) { var makeStatic = (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol); - if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(classOrInterface))) { + if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(classOrInterface))) return undefined; - } var declSourceFile = classOrInterface.getSourceFile(); var modifierFlags = (makeStatic ? 32 /* Static */ : 0) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0); var isJSFile = ts.isSourceFileJS(declSourceFile); @@ -147287,7 +150513,7 @@ var ts; function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 224 /* ClassExpression */) { + if (classDeclaration.kind === 225 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -147339,7 +150565,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 219 /* BinaryExpression */) { + if (token.parent.parent.kind === 220 /* 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))); @@ -147349,7 +150575,7 @@ var ts; var contextualType = checker.getContextualType(token.parent); typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(129 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); } function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) { var property = ts.factory.createPropertyDeclaration( @@ -147378,7 +150604,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(148 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(149 /* StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -147411,7 +150637,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(167 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); + var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(168 /* 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); @@ -147440,7 +150666,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(254 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(255 /* 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) { @@ -147465,7 +150691,12 @@ var ts; 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)); + var options = { + leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Exclude, + indentation: info.indentation + }; + changes.replaceNode(context.sourceFile, info.parentDeclaration, ts.factory.createObjectLiteralExpression(__spreadArray(__spreadArray([], info.parentDeclaration.properties, true), props, true), /*multiLine*/ true), options); } function tryGetValueFromType(context, checker, importAdder, quotePreference, type) { if (type.flags & 3 /* AnyOrUnknown */) { @@ -147524,7 +150755,7 @@ var ts; 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); + var func = codefix.createSignatureDeclarationFromSignature(212 /* 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 */) { @@ -147888,8 +151119,8 @@ var ts; (function (codefix) { codefix.registerCodeFix({ errorCodes: [ - ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, - ts.Diagnostics.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.code, + ts.Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, ], getCodeActions: function (context) { var compilerOptions = context.program.getCompilerOptions(); @@ -148018,7 +151249,7 @@ var ts; var didYouMeanStaticMemberCode = ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0.code; var errorCodes = [ ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0.code, - ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies.code, + ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression.code, didYouMeanStaticMemberCode, ]; codefix.registerCodeFix({ @@ -148041,7 +151272,7 @@ var ts; }); function getInfo(sourceFile, pos, diagCode) { var node = ts.getTokenAtPosition(sourceFile, pos); - if (ts.isIdentifier(node)) { + if (ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) { return { node: node, className: diagCode === didYouMeanStaticMemberCode ? ts.getContainingClass(node).name.text : undefined }; } } @@ -148169,7 +151400,7 @@ var ts; ]; } var result = []; - if (token.kind === 136 /* InferKeyword */) { + if (token.kind === 137 /* 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)); @@ -148211,7 +151442,7 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 136 /* InferKeyword */ || isImport(token)) { + if (token.kind === 137 /* InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { @@ -148240,7 +151471,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 136 /* InferKeyword */) { + if (token.kind === 137 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -148251,7 +151482,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(153 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -148261,7 +151492,7 @@ var ts; } function isImport(token) { return token.kind === 100 /* ImportKeyword */ - || token.kind === 79 /* Identifier */ && (token.parent.kind === 268 /* ImportSpecifier */ || token.parent.kind === 265 /* ImportClause */); + || token.kind === 79 /* Identifier */ && (token.parent.kind === 269 /* ImportSpecifier */ || token.parent.kind === 266 /* ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { @@ -148271,7 +151502,7 @@ var ts; return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 235 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 236 /* VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -148280,7 +151511,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 === 136 /* InferKeyword */) { + if (token.kind === 137 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -148296,14 +151527,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 162 /* Parameter */: - case 161 /* TypeParameter */: + case 163 /* Parameter */: + case 162 /* TypeParameter */: return true; - case 252 /* VariableDeclaration */: { + case 253 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 242 /* ForOfStatement */: - case 241 /* ForInStatement */: + case 243 /* ForOfStatement */: + case 242 /* ForInStatement */: return true; } } @@ -148353,8 +151584,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 167 /* MethodDeclaration */: - case 169 /* Constructor */: + case 168 /* MethodDeclaration */: + case 170 /* 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); @@ -148384,17 +151615,17 @@ var ts; } } return true; - case 254 /* FunctionDeclaration */: { + case 255 /* FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 212 /* FunctionExpression */: + case 213 /* 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 171 /* SetAccessor */: + case 172 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -148452,7 +151683,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 237 /* IfStatement */: + case 238 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -148463,8 +151694,8 @@ var ts; return; } // falls through - case 239 /* WhileStatement */: - case 240 /* ForStatement */: + case 240 /* WhileStatement */: + case 241 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -148537,7 +151768,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 === 309 /* JSDocNullableType */) { + if (typeNode.kind === 312 /* 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)); @@ -148557,7 +151788,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 309 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 312 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -148574,22 +151805,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - 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 */: + case 228 /* AsExpression */: + case 173 /* CallSignature */: + case 174 /* ConstructSignature */: + case 255 /* FunctionDeclaration */: + case 171 /* GetAccessor */: + case 175 /* IndexSignature */: + case 194 /* MappedType */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 163 /* Parameter */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 172 /* SetAccessor */: + case 258 /* TypeAliasDeclaration */: + case 210 /* TypeAssertionExpression */: + case 253 /* VariableDeclaration */: return true; default: return false; @@ -148691,15 +151922,16 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); break; - case 212 /* ArrowFunction */: - insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); + case 213 /* ArrowFunction */: + var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */; + insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters); break; default: return; @@ -148717,7 +151949,7 @@ var ts; changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 130 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 131 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -148826,7 +152058,9 @@ var ts; var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host, preferences = context.preferences; var token = ts.getTokenAtPosition(sourceFile, start); var declaration; - var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host, preferences); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { + declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host, preferences); + }); var name = declaration && ts.getNameOfDeclaration(declaration); return !name || changes.length === 0 ? undefined : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; @@ -149031,7 +152265,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 !== 164 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 165 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -149107,14 +152341,14 @@ var ts; 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), true), unmergedNewTags, true))); - var jsDocNode = parent.kind === 212 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var jsDocNode = parent.kind === 213 /* 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 === 165 /* PropertyDeclaration */) { + if (signature.parent.kind === 166 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -149124,14 +152358,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 335 /* JSDocParameterTag */: { + case 338 /* 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 336 /* JSDocReturnTag */: + case 339 /* JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -149156,19 +152390,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 169 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 133 /* ConstructorKeyword */, sourceFile); + case 170 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 134 /* ConstructorKeyword */, sourceFile); break; - case 212 /* ArrowFunction */: - case 211 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 212 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 254 /* FunctionDeclaration */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 255 /* FunctionDeclaration */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: searchToken = containingFunction.name; break; } @@ -149310,24 +152544,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 218 /* PostfixUnaryExpression */: + case 219 /* PostfixUnaryExpression */: usage.isNumber = true; break; - case 217 /* PrefixUnaryExpression */: + case 218 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 287 /* CaseClause */: - case 288 /* DefaultClause */: + case 288 /* CaseClause */: + case 289 /* DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 206 /* CallExpression */: - case 207 /* NewExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -149335,20 +152569,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 291 /* PropertyAssignment */: - case 292 /* ShorthandPropertyAssignment */: + case 294 /* PropertyAssignment */: + case 295 /* ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 165 /* PropertyDeclaration */: + case 166 /* PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 252 /* VariableDeclaration */: { + case 253 /* 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. @@ -149470,7 +152704,7 @@ var ts; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 252 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 253 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); @@ -149498,7 +152732,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 206 /* CallExpression */) { + if (parent.kind === 207 /* CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -149769,7 +153003,7 @@ var ts; function getSignatureFromCalls(calls) { var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_15 = function (i) { + var _loop_16 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { @@ -149778,7 +153012,7 @@ var ts; parameters.push(symbol); }; for (var i = 0; i < length; i++) { - _loop_15(i); + _loop_16(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); @@ -149917,7 +153151,7 @@ var ts; for (var _i = 0, possiblyMissingSymbols_1 = possiblyMissingSymbols; _i < possiblyMissingSymbols_1.length; _i++) { var symbol = possiblyMissingSymbols_1[_i]; if (!classMembers.has(symbol.escapedName)) { - addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement); + addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement, /* body */ undefined); } } } @@ -149929,10 +153163,19 @@ var ts; }; } codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver; - /** - * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. - */ - function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement) { + var PreserveOptionalFlags; + (function (PreserveOptionalFlags) { + PreserveOptionalFlags[PreserveOptionalFlags["Method"] = 1] = "Method"; + PreserveOptionalFlags[PreserveOptionalFlags["Property"] = 2] = "Property"; + PreserveOptionalFlags[PreserveOptionalFlags["All"] = 3] = "All"; + })(PreserveOptionalFlags = codefix.PreserveOptionalFlags || (codefix.PreserveOptionalFlags = {})); + /** + * `addClassElement` will not be called if we can't figure out a representation for `symbol` in `enclosingDeclaration`. + * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub. + */ + function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) { + if (preserveOptional === void 0) { preserveOptional = 3 /* All */; } + if (isAmbient === void 0) { isAmbient = false; } var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return undefined; @@ -149945,11 +153188,11 @@ var ts; var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); + var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */) || isAmbient; var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 164 /* PropertySignature */: - case 165 /* PropertyDeclaration */: + case 165 /* PropertySignature */: + case 166 /* PropertyDeclaration */: var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { @@ -149960,11 +153203,11 @@ var ts; } } addClassElement(ts.factory.createPropertyDeclaration( - /*decorators*/ undefined, modifiers, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: { + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -149981,20 +153224,20 @@ var ts; var accessor = orderedAccessors_1[_i]; if (ts.isGetAccessorDeclaration(accessor)) { addClassElement(ts.factory.createGetAccessorDeclaration( - /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(quotePreference))); + /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : body || createStubbedMethodBody(quotePreference))); } else { ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); var parameter = ts.getSetAccessorValueParameter(accessor); var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; addClassElement(ts.factory.createSetAccessorDeclaration( - /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(quotePreference))); + /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : body || createStubbedMethodBody(quotePreference))); } } break; } - case 166 /* MethodSignature */: - case 167 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 168 /* 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 @@ -150009,7 +153252,7 @@ var ts; if (declarations.length === 1) { ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; - outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(quotePreference)); + outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : body || createStubbedMethodBody(quotePreference)); break; } for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) { @@ -150020,21 +153263,22 @@ var ts; if (!ambient) { if (declarations.length > signatures.length) { var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); - outputMethod(quotePreference, signature, modifiers, name, createStubbedMethodBody(quotePreference)); + outputMethod(quotePreference, signature, modifiers, name, body || createStubbedMethodBody(quotePreference)); } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body)); } } break; } function outputMethod(quotePreference, signature, modifiers, name, body) { - var method = createSignatureDeclarationFromSignature(167 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder); + var method = createSignatureDeclarationFromSignature(168 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder); if (method) addClassElement(method); } } + codefix.addNewNodeForMemberSymbol = addNewNodeForMemberSymbol; function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) { var program = context.program; var checker = program.getTypeChecker(); @@ -150135,7 +153379,7 @@ var ts; var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); - if (kind === 167 /* MethodDeclaration */) { + if (kind === 168 /* MethodDeclaration */) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, ts.isInterfaceDeclaration(contextNode) ? undefined : createStubbedMethodBody(quotePreference)); @@ -150166,13 +153410,13 @@ 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(129 /* AnyKeyword */), + /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } return parameters; } - function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) { + function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body) { /** This is *a* signature with the maximal number of arguments, * such that if there is a "maximal" signature without rest arguments, * this is one of them. @@ -150194,7 +153438,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(129 /* AnyKeyword */)); + var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); var restParameter = ts.factory.createParameterDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", @@ -150203,7 +153447,7 @@ var ts; parameters.push(restParameter); } return createStubbedMethod(modifiers, name, optional, - /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference); + /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference, body); } function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) { if (ts.length(signatures)) { @@ -150211,10 +153455,10 @@ var ts; return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); } } - function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) { + function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(quotePreference)); + /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); } function createStubbedMethodBody(quotePreference) { return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference); @@ -150311,7 +153555,7 @@ var ts; return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); } function importSymbols(importAdder, symbols) { - symbols.forEach(function (s) { return importAdder.addImportFromExportedSymbol(s, /*usageIsTypeOnly*/ true); }); + symbols.forEach(function (s) { return importAdder.addImportFromExportedSymbol(s, /*isValidTypeOnlyUseSite*/ true); }); } codefix.importSymbols = importSymbols; })(codefix = ts.codefix || (ts.codefix = {})); @@ -150421,7 +153665,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 162 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 163 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -150498,7 +153742,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, true), [ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)], false)); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */)], false)); } } return typeNode; @@ -150557,7 +153801,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 206 /* CallExpression */ : 207 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 207 /* CallExpression */ : 208 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -150675,7 +153919,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(151 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(152 /* 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)); @@ -150756,7 +154000,7 @@ var ts; var allowSyntheticDefaults = info.allowSyntheticDefaults, defaultImportName = info.defaultImportName, namedImports = info.namedImports, statement = info.statement, required = info.required; changes.replaceNode(sourceFile, statement, defaultImportName && !allowSyntheticDefaults ? ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, defaultImportName, ts.factory.createExternalModuleReference(required)) - : ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, namedImports), required)); + : ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, namedImports), required, /*assertClause*/ undefined)); } function getInfo(sourceFile, program, pos) { var parent = ts.getTokenAtPosition(sourceFile, pos).parent; @@ -150783,7 +154027,7 @@ var ts; if (!ts.isIdentifier(element.name) || element.initializer) { return undefined; } - importSpecifiers.push(ts.factory.createImportSpecifier(ts.tryCast(element.propertyName, ts.isIdentifier), element.name)); + importSpecifiers.push(ts.factory.createImportSpecifier(/*isTypeOnly*/ false, ts.tryCast(element.propertyName, ts.isIdentifier), element.name)); } if (importSpecifiers.length) { return ts.factory.createNamedImports(importSpecifiers); @@ -150890,7 +154134,7 @@ var ts; function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); 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"); + ts.Debug.assert(token.parent.kind === 199 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -151018,8 +154262,9 @@ 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(143 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, - /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type); + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(144 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type, + /*members*/ undefined); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [ mappedIntersectionType ], false), (otherMembers.length ? [ts.factory.createTypeLiteralNode(otherMembers)] : ts.emptyArray), true)); @@ -151075,7 +154320,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 131 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -151125,10 +154370,10 @@ var ts; return; } var importClause = ts.Debug.checkDefined(importDeclaration.importClause); - changes.replaceNode(context.sourceFile, importDeclaration, ts.factory.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.factory.updateImportClause(importClause, importClause.isTypeOnly, importClause.name, /*namedBindings*/ undefined), importDeclaration.moduleSpecifier)); + changes.replaceNode(context.sourceFile, importDeclaration, ts.factory.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.factory.updateImportClause(importClause, importClause.isTypeOnly, importClause.name, /*namedBindings*/ undefined), importDeclaration.moduleSpecifier, importDeclaration.assertClause)); changes.insertNodeAfter(context.sourceFile, importDeclaration, ts.factory.createImportDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.factory.updateImportClause(importClause, importClause.isTypeOnly, /*name*/ undefined, importClause.namedBindings), importDeclaration.moduleSpecifier)); + /*modifiers*/ undefined, ts.factory.updateImportClause(importClause, importClause.isTypeOnly, /*name*/ undefined, importClause.namedBindings), importDeclaration.moduleSpecifier, importDeclaration.assertClause)); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -151181,9 +154426,8 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var info = getInfo(sourceFile, context.span.start, context.errorCode); - if (!info) { + if (!info) return undefined; - } var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Change_0_to_1, ";", ","], fixId, [ts.Diagnostics.Change_0_to_1, ";", ","])]; }, @@ -151362,19 +154606,19 @@ var ts; : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; }; switch (exportNode.kind) { - case 254 /* FunctionDeclaration */: - case 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: - case 258 /* EnumDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 259 /* ModuleDeclaration */: { + case 255 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: + case 259 /* EnumDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 260 /* ModuleDeclaration */: { var node = exportNode; if (!node.name) return undefined; return noSymbolError(node.name) || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 235 /* VariableStatement */: { + case 236 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -151387,7 +154631,7 @@ var ts; return noSymbolError(decl.name) || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 269 /* ExportAssignment */: { + case 270 /* ExportAssignment */: { var node = exportNode; if (node.isExportEquals) return undefined; @@ -151417,12 +154661,12 @@ var ts; else { var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 254 /* FunctionDeclaration */: - case 255 /* ClassDeclaration */: - case 256 /* InterfaceDeclaration */: + case 255 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: + case 257 /* InterfaceDeclaration */: changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); break; - case 235 /* VariableStatement */: + case 236 /* 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) { @@ -151431,9 +154675,9 @@ var ts; break; } // falls through - case 258 /* EnumDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 259 /* ModuleDeclaration */: + case 259 /* EnumDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 260 /* 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))); @@ -151460,18 +154704,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 268 /* ImportSpecifier */: - case 273 /* ExportSpecifier */: { + case 269 /* ImportSpecifier */: + case 274 /* 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 265 /* ImportClause */: { + case 266 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -151480,7 +154724,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 266 /* NamespaceImport */) { + else if (namedBindings.kind === 267 /* 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 */; @@ -151501,11 +154745,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 268 /* ImportSpecifier */: { + case 269 /* 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); @@ -151518,7 +154762,7 @@ var ts; } break; } - case 273 /* ExportSpecifier */: { + case 274 /* 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";` @@ -151531,10 +154775,10 @@ var ts; } } function makeImportSpecifier(propertyName, name) { - return ts.factory.createImportSpecifier(propertyName === name ? undefined : ts.factory.createIdentifier(propertyName), ts.factory.createIdentifier(name)); + return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName === name ? undefined : ts.factory.createIdentifier(propertyName), ts.factory.createIdentifier(name)); } function makeExportSpecifier(propertyName, name) { - return ts.factory.createExportSpecifier(propertyName === name ? undefined : ts.factory.createIdentifier(propertyName), ts.factory.createIdentifier(name)); + return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, propertyName === name ? undefined : ts.factory.createIdentifier(propertyName), ts.factory.createIdentifier(name)); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -151564,7 +154808,7 @@ var ts; if (!info) return ts.emptyArray; if (!refactor.isRefactorErrorInfo(info)) { - var namespaceImport = info.kind === 266 /* NamespaceImport */; + var namespaceImport = info.kind === 267 /* NamespaceImport */; var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction; return [{ name: refactorName, description: action.description, actions: [action] }]; } @@ -151595,7 +154839,9 @@ var ts; var importDecl = considerPartialSpans ? ts.findAncestor(token, ts.isImportDeclaration) : ts.getParentNodeInSpan(token, file, span); if (!importDecl || !ts.isImportDeclaration(importDecl)) return { error: "Selection is not an import declaration." }; - if (importDecl.getEnd() < span.start + span.length) + var end = span.start + span.length; + var nextToken = ts.findNextToken(importDecl, importDecl.parent, file); + if (nextToken && end > nextToken.getStart()) return undefined; var importClause = importDecl.importClause; if (!importClause) { @@ -151608,7 +154854,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 266 /* NamespaceImport */) { + if (toConvert.kind === 267 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -151645,7 +154891,7 @@ var ts; } var importSpecifiers = []; exportNameToImportName.forEach(function (name, propertyName) { - importSpecifiers.push(ts.factory.createImportSpecifier(name === propertyName ? undefined : ts.factory.createIdentifier(propertyName), ts.factory.createIdentifier(name))); + importSpecifiers.push(ts.factory.createImportSpecifier(/*isTypeOnly*/ false, name === propertyName ? undefined : ts.factory.createIdentifier(propertyName), ts.factory.createIdentifier(name))); }); var importDecl = toConvert.parent.parent; if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { @@ -151694,7 +154940,7 @@ var ts; // 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 _loop_17 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName); @@ -151711,18 +154957,18 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_16(element); + _loop_17(element); } changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName))); 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)); + return ts.factory.createImportSpecifier(element.isTypeOnly, 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) { - return ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, elements && elements.length ? ts.factory.createNamedImports(elements) : undefined), old.moduleSpecifier); + return ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, elements && elements.length ? ts.factory.createNamedImports(elements) : undefined), old.moduleSpecifier, /*assertClause*/ undefined); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -152031,27 +155277,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 166 /* MethodSignature */: { + case 167 /* MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 167 /* MethodDeclaration */: { + case 168 /* 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 172 /* CallSignature */: { + case 173 /* CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 169 /* Constructor */: { + case 170 /* Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 173 /* ConstructSignature */: { + case 174 /* ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 254 /* FunctionDeclaration */: { + case 255 /* FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -152083,7 +155329,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(129 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); @@ -152103,12 +155349,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 166 /* MethodSignature */: - case 167 /* MethodDeclaration */: - case 172 /* CallSignature */: - case 169 /* Constructor */: - case 173 /* ConstructSignature */: - case 254 /* FunctionDeclaration */: + case 167 /* MethodSignature */: + case 168 /* MethodDeclaration */: + case 173 /* CallSignature */: + case 170 /* Constructor */: + case 174 /* ConstructSignature */: + case 255 /* FunctionDeclaration */: return true; } return false; @@ -152497,20 +155743,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 165 /* PropertyDeclaration */) { + if (current.kind === 166 /* PropertyDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 162 /* Parameter */) { + else if (current.kind === 163 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 169 /* Constructor */) { + if (ctorOrMethod.kind === 170 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 167 /* MethodDeclaration */) { + else if (current.kind === 168 /* MethodDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -152553,7 +155799,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 252 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 253 /* 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`! @@ -152565,16 +155811,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; 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 === 206 /* CallExpression */) { + if (node.parent.kind === 207 /* 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)) { @@ -152586,7 +155832,7 @@ var ts; rangeFacts |= RangeFacts.UsesThis; } break; - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -152600,39 +155846,39 @@ var ts; } }); // falls through - case 255 /* ClassDeclaration */: - case 254 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: + case 255 /* 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 224 /* ClassExpression */: - case 211 /* FunctionExpression */: - case 167 /* MethodDeclaration */: - case 169 /* Constructor */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: + case 225 /* ClassExpression */: + case 212 /* FunctionExpression */: + case 168 /* MethodDeclaration */: + case 170 /* Constructor */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 237 /* IfStatement */: + case 238 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 250 /* TryStatement */: + case 251 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 233 /* Block */: - if (node.parent && node.parent.kind === 250 /* TryStatement */ && node.parent.finallyBlock === node) { + case 234 /* Block */: + if (node.parent && node.parent.kind === 251 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 288 /* DefaultClause */: - case 287 /* CaseClause */: + case 289 /* DefaultClause */: + case 288 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -152644,19 +155890,19 @@ var ts; break; } switch (node.kind) { - case 190 /* ThisType */: + case 191 /* ThisType */: case 108 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 248 /* LabeledStatement */: { + case 249 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 244 /* BreakStatement */: - case 243 /* ContinueStatement */: { + case 245 /* BreakStatement */: + case 244 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -152665,20 +155911,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 244 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 245 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 216 /* AwaitExpression */: + case 217 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 222 /* YieldExpression */: + case 223 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -152744,7 +155990,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 === 162 /* Parameter */) { + if (current.kind === 163 /* 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; } @@ -152755,7 +156001,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 300 /* SourceFile */) { + if (current.kind === 303 /* SourceFile */) { return scopes; } } @@ -152845,32 +156091,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 169 /* Constructor */: + case 170 /* Constructor */: return "constructor"; - case 211 /* FunctionExpression */: - case 254 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : ts.ANONYMOUS; - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return "arrow function"; - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 170 /* GetAccessor */: + case 171 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 171 /* SetAccessor */: + case 172 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 255 /* ClassDeclaration */ + return scope.kind === 256 /* 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 === 260 /* ModuleBlock */ + return scope.kind === 261 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -152943,7 +156189,7 @@ var ts; modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(130 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(131 /* AsyncKeyword */)); } newFunction = ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, @@ -152951,7 +156197,7 @@ var ts; } else { newFunction = ts.factory.createFunctionDeclaration( - /*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); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* 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; @@ -153096,9 +156342,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 151 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 152 /* UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(151 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */)]); } } /** @@ -153116,7 +156362,7 @@ var ts; var variableType = isJS || !checker.isContextSensitive(node) ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 - var initializer = transformConstantInitializer(node, substitutions); + var initializer = transformConstantInitializer(ts.skipParentheses(node), substitutions); (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); @@ -153127,7 +156373,7 @@ var ts; if (rangeFacts & RangeFacts.InStaticRegion) { modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(143 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(144 /* ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -153159,7 +156405,7 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 236 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 237 /* 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( @@ -153178,7 +156424,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 236 /* ExpressionStatement */) { + if (node.parent.kind === 237 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -153306,7 +156552,7 @@ var ts; } var returnValueProperty; var ignoreReturns = false; - var statements = ts.factory.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.factory.createReturnStatement(body)]); + var statements = ts.factory.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.factory.createReturnStatement(ts.skipParentheses(body))]); // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions if (hasWritesOrVariableDeclarations || substitutions.size) { var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); @@ -153566,7 +156812,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_17 = function (i) { + var _loop_18 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -153606,7 +156852,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_17(i); + _loop_18(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -153822,30 +157068,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 294 /* EnumMember */: + case 297 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 264 /* ImportDeclaration */ && - parent.kind !== 268 /* ImportSpecifier */; - case 223 /* SpreadElement */: - case 199 /* ObjectBindingPattern */: - case 201 /* BindingElement */: + return parent.kind !== 265 /* ImportDeclaration */ && + parent.kind !== 269 /* ImportSpecifier */; + case 224 /* SpreadElement */: + case 200 /* ObjectBindingPattern */: + case 202 /* BindingElement */: return false; case 79 /* Identifier */: - return parent.kind !== 201 /* BindingElement */ && - parent.kind !== 268 /* ImportSpecifier */ && - parent.kind !== 273 /* ExportSpecifier */; + return parent.kind !== 202 /* BindingElement */ && + parent.kind !== 269 /* ImportSpecifier */ && + parent.kind !== 274 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 233 /* Block */: - case 300 /* SourceFile */: - case 260 /* ModuleBlock */: - case 287 /* CaseClause */: + case 234 /* Block */: + case 303 /* SourceFile */: + case 261 /* ModuleBlock */: + case 288 /* CaseClause */: return true; default: return false; @@ -154230,11 +157476,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return true; - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -154261,17 +157507,17 @@ var ts; deleteMovedStatements(oldFile, toMove.ranges, changes); return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true); } - var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator; + var useEsModuleSyntax = !!oldFile.externalModuleIndicator; var quotePreference = ts.getQuotePreference(oldFile, preferences); - var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, quotePreference); + var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEsModuleSyntax, quotePreference); if (importsFromNewFile) { ts.insertImports(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true); } deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference); - var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax); + var imports = getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference); + var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax); if (imports.length && body.length) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [ 4 /* NewLineTrivia */ @@ -154295,10 +157541,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_18 = function (sourceFile) { + var _loop_19 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_19 = function (statement) { + var _loop_20 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -154320,22 +157566,22 @@ var ts; }; for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) { var statement = _c[_b]; - _loop_19(statement); + _loop_20(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_18(sourceFile); + _loop_19(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 264 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 266 /* NamespaceImport */ ? + case 265 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 267 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return node.name; - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); @@ -154366,20 +157612,21 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: return ts.factory.createImportDeclaration( - /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString); - case 263 /* ImportEqualsDeclaration */: + /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString, + /*assertClause*/ undefined); + case 264 /* ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 252 /* VariableDeclaration */: + case 253 /* 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 === 264 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 263 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 265 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 264 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -154417,7 +157664,7 @@ var ts; function makeImportOrRequire(defaultImport, imports, path, useEs6Imports, quotePreference) { path = ts.ensurePathIsNonModuleName(path); if (useEs6Imports) { - var specifiers = imports.map(function (i) { return ts.factory.createImportSpecifier(/*propertyName*/ undefined, ts.factory.createIdentifier(i)); }); + var specifiers = imports.map(function (i) { return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.factory.createIdentifier(i)); }); return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { @@ -154449,15 +157696,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -154470,7 +157717,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 266 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 267 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -154482,7 +157729,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 === 267 /* NamedImports */) { + else if (namedBindings.kind === 268 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -154500,9 +157747,9 @@ var ts; changes.delete(sourceFile, name); } break; - case 200 /* ArrayBindingPattern */: + case 201 /* ArrayBindingPattern */: break; - case 199 /* ObjectBindingPattern */: + case 200 /* 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); } @@ -154517,7 +157764,7 @@ var ts; break; } } - function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, quotePreference) { + function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEsModuleSyntax, quotePreference) { var copiedOldImports = []; for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) { var oldStatement = _a[_i]; @@ -154542,7 +157789,7 @@ var ts; continue; var top = getTopLevelDeclarationStatement(decl); if (markSeenTop(top)) { - addExportToChanges(oldFile, top, name, changes, useEs6ModuleSyntax); + addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } if (ts.hasSyntacticModifier(decl, 512 /* Default */)) { oldFileDefault = name; @@ -154552,7 +157799,7 @@ var ts; } } }); - ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax, quotePreference)); + ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEsModuleSyntax, quotePreference)); return copiedOldImports; } function makeUniqueModuleName(moduleName, extension, inDirectory, host) { @@ -154632,14 +157879,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 263 /* ImportEqualsDeclaration */: - case 268 /* ImportSpecifier */: - case 265 /* ImportClause */: - case 266 /* NamespaceImport */: + case 264 /* ImportEqualsDeclaration */: + case 269 /* ImportSpecifier */: + case 266 /* ImportClause */: + case 267 /* NamespaceImport */: return true; - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 201 /* BindingElement */: + case 202 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -154651,19 +157898,19 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 264 /* ImportDeclaration */: { + case 265 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; var defaultImport = clause.name && keep(clause.name) ? clause.name : undefined; var namedBindings = clause.namedBindings && filterNamedBindings(clause.namedBindings, keep); return defaultImport || namedBindings - ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier) + ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) : undefined; } - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 252 /* VariableDeclaration */: { + case 253 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -154672,7 +157919,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 266 /* NamespaceImport */) { + if (namedBindings.kind === 267 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -154684,9 +157931,9 @@ var ts; switch (name.kind) { case 79 /* Identifier */: return keep(name) ? name : undefined; - case 200 /* ArrayBindingPattern */: + case 201 /* ArrayBindingPattern */: return name; - case 199 /* ObjectBindingPattern */: { + case 200 /* 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; @@ -154743,13 +157990,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 254 /* FunctionDeclaration */: - case 255 /* ClassDeclaration */: - case 259 /* ModuleDeclaration */: - case 258 /* EnumDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 256 /* InterfaceDeclaration */: - case 263 /* ImportEqualsDeclaration */: + case 255 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: + case 260 /* ModuleDeclaration */: + case 259 /* EnumDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 257 /* InterfaceDeclaration */: + case 264 /* ImportEqualsDeclaration */: return true; default: return false; @@ -154757,17 +158004,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 254 /* FunctionDeclaration */: - case 255 /* ClassDeclaration */: - case 259 /* ModuleDeclaration */: - case 258 /* EnumDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 256 /* InterfaceDeclaration */: - case 263 /* ImportEqualsDeclaration */: + case 255 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: + case 260 /* ModuleDeclaration */: + case 259 /* EnumDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 257 /* InterfaceDeclaration */: + case 264 /* ImportEqualsDeclaration */: return cb(statement); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 236 /* ExpressionStatement */: { + case 237 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -154779,8 +158026,8 @@ var ts; switch (name.kind) { case 79 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 200 /* ArrayBindingPattern */: - case 199 /* ObjectBindingPattern */: + case 201 /* ArrayBindingPattern */: + case 200 /* 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); @@ -154791,9 +158038,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 252 /* VariableDeclaration */: + case 253 /* VariableDeclaration */: return d.parent.parent; - case 201 /* BindingElement */: + case 202 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -154825,23 +158072,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 257 /* TypeAliasDeclaration */: + case 258 /* TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 256 /* InterfaceDeclaration */: + case 257 /* InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 236 /* ExpressionStatement */: + case 237 /* 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); @@ -154852,18 +158099,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 254 /* FunctionDeclaration */: - case 255 /* ClassDeclaration */: + case 255 /* FunctionDeclaration */: + case 256 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 259 /* ModuleDeclaration */: - case 258 /* EnumDeclaration */: - case 257 /* TypeAliasDeclaration */: - case 256 /* InterfaceDeclaration */: - case 263 /* ImportEqualsDeclaration */: + case 260 /* ModuleDeclaration */: + case 259 /* EnumDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 257 /* InterfaceDeclaration */: + case 264 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 236 /* ExpressionStatement */: + case 237 /* 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); @@ -154934,13 +158181,11 @@ var ts; if (actionName === addBracesAction.name) { var returnStatement_1 = ts.factory.createReturnStatement(expression); body = ts.factory.createBlock([returnStatement_1], /* multiLine */ true); - ts.suppressLeadingAndTrailingTrivia(body); ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); } else if (actionName === removeBracesAction.name && returnStatement) { var actualExpression = expression || ts.factory.createVoidZero(); body = ts.needsParentheses(actualExpression) ? ts.factory.createParenthesizedExpression(actualExpression) : actualExpression; - ts.suppressLeadingAndTrailingTrivia(body); ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); @@ -155206,15 +158451,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 206 /* CallExpression */: - case 207 /* NewExpression */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -155224,7 +158469,7 @@ var ts; } break; // x["foo"](...) - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -155243,14 +158488,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 204 /* PropertyAccessExpression */: + case 205 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 205 /* ElementAccessExpression */: + case 206 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -155296,16 +158541,16 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 254 /* FunctionDeclaration */: + case 255 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 167 /* MethodDeclaration */: + case 168 /* 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 169 /* Constructor */: + case 170 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -155313,8 +158558,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -155464,7 +158709,7 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; @@ -155472,7 +158717,7 @@ var ts; // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 224 /* ClassExpression */: + case 225 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -155483,25 +158728,25 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 254 /* FunctionDeclaration */: + case 255 /* 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, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 167 /* MethodDeclaration */: + case 168 /* MethodDeclaration */: return [functionDeclaration.name]; - 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 */) { + case 170 /* Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 225 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 211 /* FunctionExpression */: + case 212 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; @@ -155592,11 +158837,11 @@ var ts; function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 204 /* PropertyAccessExpression */: - case 205 /* ElementAccessExpression */: + case 205 /* PropertyAccessExpression */: + case 206 /* ElementAccessExpression */: return false; - case 221 /* TemplateExpression */: - case 219 /* BinaryExpression */: + case 222 /* TemplateExpression */: + case 220 /* BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -155690,7 +158935,7 @@ var ts; var templateSpans = []; var templateHead = ts.factory.createTemplateHead(headText, rawHeadText); copyCommentFromStringLiterals(headIndexes, templateHead); - var _loop_20 = function (i) { + var _loop_21 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3]; @@ -155719,7 +158964,7 @@ var ts; }; var out_i_1; for (var i = begin; i < nodes.length; i++) { - _loop_20(i); + _loop_21(i); i = out_i_1; } return ts.factory.createTemplateExpression(templateHead, templateSpans); @@ -156044,10 +159289,10 @@ var ts; } function isConvertibleDeclaration(node) { switch (node.kind) { - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: - case 167 /* MethodDeclaration */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: + case 168 /* MethodDeclaration */: return true; default: return false; @@ -156149,8 +159394,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 304 /* FirstJSDocNode */ || kid.kind > 342 /* LastJSDocNode */; }); - return child.kind < 159 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 307 /* FirstJSDocNode */ || kid.kind > 345 /* LastJSDocNode */; }); + return child.kind < 160 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -156161,7 +159406,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 159 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 160 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -156175,7 +159420,9 @@ var ts; var children = []; if (ts.isJSDocCommentContainingNode(node)) { /** Don't add trivia for "tokens" since this is in a comment. */ - node.forEachChild(function (child) { children.push(child); }); + node.forEachChild(function (child) { + children.push(child); + }); return children; } ts.scanner.setText((sourceFile || node.getSourceFile()).text); @@ -156219,7 +159466,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(343 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(346 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { @@ -156330,13 +159577,13 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 170 /* GetAccessor */: + case 171 /* GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = ts.emptyArray; this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 171 /* SetAccessor */: + case 172 /* SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = ts.emptyArray; this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); @@ -156556,7 +159803,7 @@ var ts; } function findBaseOfDeclaration(checker, declaration, cb) { var _a; - var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 169 /* Constructor */ ? declaration.parent.parent : declaration.parent; + var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 170 /* Constructor */ ? declaration.parent.parent : declaration.parent; if (!classOrInterfaceDeclaration) { return; } @@ -156569,7 +159816,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 300 /* SourceFile */; + _this.kind = 303 /* SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -156628,10 +159875,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 254 /* FunctionDeclaration */: - case 211 /* FunctionExpression */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: + case 255 /* FunctionDeclaration */: + case 212 /* FunctionExpression */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -156651,31 +159898,31 @@ var ts; } ts.forEachChild(node, visit); break; - 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 */: + case 256 /* ClassDeclaration */: + case 225 /* ClassExpression */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: + case 259 /* EnumDeclaration */: + case 260 /* ModuleDeclaration */: + case 264 /* ImportEqualsDeclaration */: + case 274 /* ExportSpecifier */: + case 269 /* ImportSpecifier */: + case 266 /* ImportClause */: + case 267 /* NamespaceImport */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 181 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 162 /* Parameter */: + case 163 /* Parameter */: // Only consider parameter properties if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { break; } // falls through - case 252 /* VariableDeclaration */: - case 201 /* BindingElement */: { + case 253 /* VariableDeclaration */: + case 202 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -156686,12 +159933,12 @@ var ts; } } // falls through - case 294 /* EnumMember */: - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: + case 297 /* EnumMember */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: addDeclaration(node); break; - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -156704,7 +159951,7 @@ var ts; } } break; - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -156716,7 +159963,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 266 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 267 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -156725,7 +159972,7 @@ var ts; } } break; - case 219 /* BinaryExpression */: + case 220 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -157432,14 +160679,14 @@ var ts; switch (node.kind) { case 79 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); - case 204 /* PropertyAccessExpression */: - case 159 /* QualifiedName */: + case 205 /* PropertyAccessExpression */: + case 160 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); case 108 /* ThisKeyword */: - case 190 /* ThisType */: + case 191 /* ThisType */: case 106 /* SuperKeyword */: - case 195 /* NamedTupleMember */: + case 196 /* NamedTupleMember */: return true; default: return false; @@ -157479,6 +160726,8 @@ var ts; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position)); + if (!ts.Rename.nodeIsEligibleForRename(node)) + return undefined; if (ts.isIdentifier(node) && (ts.isJsxOpeningElement(node.parent) || ts.isJsxClosingElement(node.parent)) && ts.isIntrinsicJsxName(node.escapedText)) { var _a = node.parent.parent, openingElement = _a.openingElement, closingElement = _a.closingElement; return [openingElement, closingElement].map(function (node) { @@ -157492,7 +160741,7 @@ var ts; } function getReferencesAtPosition(fileName, position) { synchronizeHostData(); - return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry); + return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, function (entry, node, checker) { return ts.FindAllReferences.toReferenceEntry(entry, checker.getSymbolAtLocation(node)); }); } function getReferencesWorker(node, position, options, cb) { synchronizeHostData(); @@ -157507,8 +160756,10 @@ var ts; return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); } function getFileReferences(fileName) { + var _a; synchronizeHostData(); - return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(ts.FindAllReferences.toReferenceEntry); + var moduleSymbol = (_a = program.getSourceFile(fileName)) === null || _a === void 0 ? void 0 : _a.symbol; + return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(function (r) { return ts.FindAllReferences.toReferenceEntry(r, moduleSymbol); }); } function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { if (excludeDtsFiles === void 0) { excludeDtsFiles = false; } @@ -157544,15 +160795,15 @@ var ts; return undefined; } switch (node.kind) { - case 204 /* PropertyAccessExpression */: - case 159 /* QualifiedName */: + case 205 /* PropertyAccessExpression */: + case 160 /* QualifiedName */: case 10 /* StringLiteral */: case 95 /* FalseKeyword */: case 110 /* TrueKeyword */: case 104 /* NullKeyword */: case 106 /* SuperKeyword */: case 108 /* ThisKeyword */: - case 190 /* ThisType */: + case 191 /* ThisType */: case 79 /* Identifier */: break; // Cant create the text span @@ -157569,7 +160820,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 === 259 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 260 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -157759,10 +161010,15 @@ var ts; if (!token) return undefined; var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent - : ts.isJsxText(token) ? token.parent : undefined; + : ts.isJsxText(token) && ts.isJsxElement(token.parent) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; } + var fragment = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent + : ts.isJsxText(token) && ts.isJsxFragment(token.parent) ? token.parent : undefined; + if (fragment && isUnclosedFragment(fragment)) { + return { newText: "" }; + } } function getLinesForRange(sourceFile, textRange) { return { @@ -157974,6 +161230,10 @@ var ts; return !ts.tagNamesAreEquivalent(openingElement.tagName, closingElement.tagName) || ts.isJsxElement(parent) && ts.tagNamesAreEquivalent(openingElement.tagName, parent.openingElement.tagName) && isUnclosedTag(parent); } + function isUnclosedFragment(_a) { + var closingFragment = _a.closingFragment, parent = _a.parent; + return !!(closingFragment.flags & 65536 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); + } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); @@ -158307,7 +161567,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 275 /* ExternalModuleReference */ || + node.parent.kind === 276 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -158325,13 +161585,13 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 160 /* ComputedPropertyName */) { + if (node.parent.kind === 161 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through case 79 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 203 /* ObjectLiteralExpression */ || node.parent.parent.kind === 284 /* JsxAttributes */) && + (node.parent.parent.kind === 204 /* ObjectLiteralExpression */ || node.parent.parent.kind === 285 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -158373,7 +161633,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 205 /* ElementAccessExpression */ && + node.parent.kind === 206 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -158453,114 +161713,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 235 /* VariableStatement */: + case 236 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 252 /* VariableDeclaration */: - case 165 /* PropertyDeclaration */: - case 164 /* PropertySignature */: + case 253 /* VariableDeclaration */: + case 166 /* PropertyDeclaration */: + case 165 /* PropertySignature */: return spanInVariableDeclaration(node); - case 162 /* Parameter */: + case 163 /* Parameter */: return spanInParameterDeclaration(node); - case 254 /* FunctionDeclaration */: - case 167 /* MethodDeclaration */: - case 166 /* MethodSignature */: - case 170 /* GetAccessor */: - case 171 /* SetAccessor */: - case 169 /* Constructor */: - case 211 /* FunctionExpression */: - case 212 /* ArrowFunction */: + case 255 /* FunctionDeclaration */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 170 /* Constructor */: + case 212 /* FunctionExpression */: + case 213 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 233 /* Block */: + case 234 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 260 /* ModuleBlock */: + case 261 /* ModuleBlock */: return spanInBlock(node); - case 290 /* CatchClause */: + case 291 /* CatchClause */: return spanInBlock(node.block); - case 236 /* ExpressionStatement */: + case 237 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 245 /* ReturnStatement */: + case 246 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 239 /* WhileStatement */: + case 240 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 238 /* DoStatement */: + case 239 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 251 /* DebuggerStatement */: + case 252 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 237 /* IfStatement */: + case 238 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 248 /* LabeledStatement */: + case 249 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 244 /* BreakStatement */: - case 243 /* ContinueStatement */: + case 245 /* BreakStatement */: + case 244 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 240 /* ForStatement */: + case 241 /* ForStatement */: return spanInForStatement(node); - case 241 /* ForInStatement */: + case 242 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 242 /* ForOfStatement */: + case 243 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 247 /* SwitchStatement */: + case 248 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 287 /* CaseClause */: - case 288 /* DefaultClause */: + case 288 /* CaseClause */: + case 289 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 250 /* TryStatement */: + case 251 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 249 /* ThrowStatement */: + case 250 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 269 /* ExportAssignment */: + case 270 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 263 /* ImportEqualsDeclaration */: + case 264 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 264 /* ImportDeclaration */: + case 265 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 270 /* ExportDeclaration */: + case 271 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 255 /* ClassDeclaration */: - case 258 /* EnumDeclaration */: - case 294 /* EnumMember */: - case 201 /* BindingElement */: + case 256 /* ClassDeclaration */: + case 259 /* EnumDeclaration */: + case 297 /* EnumMember */: + case 202 /* BindingElement */: // span on complete node return textSpan(node); - case 246 /* WithStatement */: + case 247 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 163 /* Decorator */: + case 164 /* Decorator */: return spanInNodeArray(parent.decorators); - case 199 /* ObjectBindingPattern */: - case 200 /* ArrayBindingPattern */: + case 200 /* ObjectBindingPattern */: + case 201 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 256 /* InterfaceDeclaration */: - case 257 /* TypeAliasDeclaration */: + case 257 /* InterfaceDeclaration */: + case 258 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -158590,7 +161850,7 @@ var ts; case 83 /* CatchKeyword */: case 96 /* FinallyKeyword */: return spanInNextNode(node); - case 158 /* OfKeyword */: + case 159 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -158603,13 +161863,13 @@ var ts; // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern if ((node.kind === 79 /* Identifier */ || - node.kind === 223 /* SpreadElement */ || - node.kind === 291 /* PropertyAssignment */ || - node.kind === 292 /* ShorthandPropertyAssignment */) && + node.kind === 224 /* SpreadElement */ || + node.kind === 294 /* PropertyAssignment */ || + node.kind === 295 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 219 /* BinaryExpression */) { + if (node.kind === 220 /* 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 @@ -158631,22 +161891,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 238 /* DoStatement */: + case 239 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 163 /* Decorator */: + case 164 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 240 /* ForStatement */: - case 242 /* ForOfStatement */: + case 241 /* ForStatement */: + case 243 /* ForOfStatement */: return textSpan(node); - case 219 /* BinaryExpression */: + case 220 /* 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 212 /* ArrowFunction */: + case 213 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -158655,21 +161915,21 @@ var ts; } } switch (node.parent.kind) { - case 291 /* PropertyAssignment */: + case 294 /* 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 209 /* TypeAssertionExpression */: + case 210 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 252 /* VariableDeclaration */: - case 162 /* Parameter */: { + case 253 /* VariableDeclaration */: + case 163 /* 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)) { @@ -158677,7 +161937,7 @@ var ts; } break; } - case 219 /* BinaryExpression */: { + case 220 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -158707,7 +161967,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 241 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 242 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -158719,7 +161979,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 242 /* ForOfStatement */) { + parent.parent.kind === 243 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -158760,7 +162020,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 255 /* ClassDeclaration */ && functionDeclaration.kind !== 169 /* Constructor */); + (functionDeclaration.parent.kind === 256 /* ClassDeclaration */ && functionDeclaration.kind !== 170 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -158783,26 +162043,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 259 /* ModuleDeclaration */: + case 260 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 239 /* WhileStatement */: - case 237 /* IfStatement */: - case 241 /* ForInStatement */: + case 240 /* WhileStatement */: + case 238 /* IfStatement */: + case 242 /* 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 240 /* ForStatement */: - case 242 /* ForOfStatement */: + case 241 /* ForStatement */: + case 243 /* 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 === 253 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 254 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -158827,21 +162087,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 225 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 226 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 201 /* BindingElement */) { + if (bindingPattern.parent.kind === 202 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - 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; }); + ts.Debug.assert(node.kind !== 201 /* ArrayBindingPattern */ && node.kind !== 200 /* ObjectBindingPattern */); + var elements = node.kind === 203 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 226 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -158849,18 +162109,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 === 219 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 220 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 258 /* EnumDeclaration */: + case 259 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 255 /* ClassDeclaration */: + case 256 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 261 /* CaseBlock */: + case 262 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -158868,25 +162128,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 260 /* ModuleBlock */: + case 261 /* 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 258 /* EnumDeclaration */: - case 255 /* ClassDeclaration */: + case 259 /* EnumDeclaration */: + case 256 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 233 /* Block */: + case 234 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 290 /* CatchClause */: + case 291 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 261 /* CaseBlock */: + case 262 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -158894,7 +162154,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 199 /* ObjectBindingPattern */: + case 200 /* 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); @@ -158910,7 +162170,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 200 /* ArrayBindingPattern */: + case 201 /* 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); @@ -158925,12 +162185,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 238 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 206 /* CallExpression */ || - node.parent.kind === 207 /* NewExpression */) { + if (node.parent.kind === 239 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 207 /* CallExpression */ || + node.parent.kind === 208 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 210 /* ParenthesizedExpression */) { + if (node.parent.kind === 211 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -158939,21 +162199,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - 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 */: + case 212 /* FunctionExpression */: + case 255 /* FunctionDeclaration */: + case 213 /* ArrowFunction */: + case 168 /* MethodDeclaration */: + case 167 /* MethodSignature */: + case 171 /* GetAccessor */: + case 172 /* SetAccessor */: + case 170 /* Constructor */: + case 240 /* WhileStatement */: + case 239 /* DoStatement */: + case 241 /* ForStatement */: + case 243 /* ForOfStatement */: + case 207 /* CallExpression */: + case 208 /* NewExpression */: + case 211 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -158963,20 +162223,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 291 /* PropertyAssignment */ || - node.parent.kind === 162 /* Parameter */) { + node.parent.kind === 294 /* PropertyAssignment */ || + node.parent.kind === 163 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 209 /* TypeAssertionExpression */) { + if (node.parent.kind === 210 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 238 /* DoStatement */) { + if (node.parent.kind === 239 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -158984,7 +162244,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 242 /* ForOfStatement */) { + if (node.parent.kind === 243 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -159029,7 +162289,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const +var debugObjectHost = (function () { + return this; +})(); // We need to use 'null' to interface with the managed side. /* eslint-disable no-in-operator */ /* @internal */ @@ -160571,7 +163833,7 @@ var ts; } else { type = operatorOrType; - operator = 139 /* KeyOfKeyword */; + operator = 140 /* KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -160695,7 +163957,7 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.updateExportDeclaration` or the factory supplied by your transformation context instead. */ ts.updateExportDeclaration = ts.Debug.deprecate(function updateExportDeclaration(node, decorators, modifiers, exportClause, moduleSpecifier, isTypeOnly) { - return ts.factory.updateExportDeclaration(node, decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier); + return ts.factory.updateExportDeclaration(node, decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, node.assertClause); }, factoryDeprecation); /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ ts.createJSDocParamTag = ts.Debug.deprecate(function createJSDocParamTag(name, isBracketed, typeExpression, comment) { @@ -160749,7 +164011,7 @@ 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 === 300 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + return ts.setTextRangePosEnd(kind === 303 /* 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) : @@ -160778,7 +164040,7 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 209 /* TypeAssertionExpression */; + return node.kind === 210 /* TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1",