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 bba168d37e72..b86a3a29970a 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.2"; + const versionMajorMinor = "4.3"; /** The version of the TypeScript compiler release */ const version: string; /** @@ -260,192 +260,196 @@ declare namespace ts { FromKeyword = 153, GlobalKeyword = 154, BigIntKeyword = 155, - OfKeyword = 156, - QualifiedName = 157, - ComputedPropertyName = 158, - TypeParameter = 159, - Parameter = 160, - Decorator = 161, - PropertySignature = 162, - PropertyDeclaration = 163, - MethodSignature = 164, - MethodDeclaration = 165, - Constructor = 166, - GetAccessor = 167, - SetAccessor = 168, - CallSignature = 169, - ConstructSignature = 170, - IndexSignature = 171, - TypePredicate = 172, - TypeReference = 173, - FunctionType = 174, - ConstructorType = 175, - TypeQuery = 176, - TypeLiteral = 177, - ArrayType = 178, - TupleType = 179, - OptionalType = 180, - RestType = 181, - UnionType = 182, - IntersectionType = 183, - ConditionalType = 184, - InferType = 185, - ParenthesizedType = 186, - ThisType = 187, - TypeOperator = 188, - IndexedAccessType = 189, - MappedType = 190, - LiteralType = 191, - NamedTupleMember = 192, - TemplateLiteralType = 193, - TemplateLiteralTypeSpan = 194, - ImportType = 195, - ObjectBindingPattern = 196, - ArrayBindingPattern = 197, - BindingElement = 198, - ArrayLiteralExpression = 199, - ObjectLiteralExpression = 200, - PropertyAccessExpression = 201, - ElementAccessExpression = 202, - CallExpression = 203, - NewExpression = 204, - TaggedTemplateExpression = 205, - TypeAssertionExpression = 206, - ParenthesizedExpression = 207, - FunctionExpression = 208, - ArrowFunction = 209, - DeleteExpression = 210, - TypeOfExpression = 211, - VoidExpression = 212, - AwaitExpression = 213, - PrefixUnaryExpression = 214, - PostfixUnaryExpression = 215, - BinaryExpression = 216, - ConditionalExpression = 217, - TemplateExpression = 218, - YieldExpression = 219, - SpreadElement = 220, - ClassExpression = 221, - OmittedExpression = 222, - ExpressionWithTypeArguments = 223, - AsExpression = 224, - NonNullExpression = 225, - MetaProperty = 226, - SyntheticExpression = 227, - TemplateSpan = 228, - SemicolonClassElement = 229, - Block = 230, - EmptyStatement = 231, - VariableStatement = 232, - ExpressionStatement = 233, - IfStatement = 234, - DoStatement = 235, - WhileStatement = 236, - ForStatement = 237, - ForInStatement = 238, - ForOfStatement = 239, - ContinueStatement = 240, - BreakStatement = 241, - ReturnStatement = 242, - WithStatement = 243, - SwitchStatement = 244, - LabeledStatement = 245, - ThrowStatement = 246, - TryStatement = 247, - DebuggerStatement = 248, - VariableDeclaration = 249, - VariableDeclarationList = 250, - FunctionDeclaration = 251, - ClassDeclaration = 252, - InterfaceDeclaration = 253, - TypeAliasDeclaration = 254, - EnumDeclaration = 255, - ModuleDeclaration = 256, - ModuleBlock = 257, - CaseBlock = 258, - NamespaceExportDeclaration = 259, - ImportEqualsDeclaration = 260, - ImportDeclaration = 261, - ImportClause = 262, - NamespaceImport = 263, - NamedImports = 264, - ImportSpecifier = 265, - ExportAssignment = 266, - ExportDeclaration = 267, - NamedExports = 268, - NamespaceExport = 269, - ExportSpecifier = 270, - MissingDeclaration = 271, - ExternalModuleReference = 272, - JsxElement = 273, - JsxSelfClosingElement = 274, - JsxOpeningElement = 275, - JsxClosingElement = 276, - JsxFragment = 277, - JsxOpeningFragment = 278, - JsxClosingFragment = 279, - JsxAttribute = 280, - JsxAttributes = 281, - JsxSpreadAttribute = 282, - JsxExpression = 283, - CaseClause = 284, - DefaultClause = 285, - HeritageClause = 286, - CatchClause = 287, - PropertyAssignment = 288, - ShorthandPropertyAssignment = 289, - SpreadAssignment = 290, - EnumMember = 291, - UnparsedPrologue = 292, - UnparsedPrepend = 293, - UnparsedText = 294, - UnparsedInternalText = 295, - UnparsedSyntheticReference = 296, - SourceFile = 297, - Bundle = 298, - UnparsedSource = 299, - InputFiles = 300, - JSDocTypeExpression = 301, - JSDocNameReference = 302, - JSDocAllType = 303, - JSDocUnknownType = 304, - JSDocNullableType = 305, - JSDocNonNullableType = 306, - JSDocOptionalType = 307, - JSDocFunctionType = 308, - JSDocVariadicType = 309, - JSDocNamepathType = 310, - JSDocComment = 311, - JSDocTypeLiteral = 312, - JSDocSignature = 313, - JSDocTag = 314, - JSDocAugmentsTag = 315, - JSDocImplementsTag = 316, - JSDocAuthorTag = 317, - JSDocDeprecatedTag = 318, - JSDocClassTag = 319, - JSDocPublicTag = 320, - JSDocPrivateTag = 321, - JSDocProtectedTag = 322, - JSDocReadonlyTag = 323, - JSDocCallbackTag = 324, - JSDocEnumTag = 325, - JSDocParameterTag = 326, - JSDocReturnTag = 327, - JSDocThisTag = 328, - JSDocTypeTag = 329, - JSDocTemplateTag = 330, - JSDocTypedefTag = 331, - JSDocSeeTag = 332, - JSDocPropertyTag = 333, - SyntaxList = 334, - NotEmittedStatement = 335, - PartiallyEmittedExpression = 336, - CommaListExpression = 337, - MergeDeclarationMarker = 338, - EndOfDeclarationMarker = 339, - SyntheticReferenceExpression = 340, - Count = 341, + OverrideKeyword = 156, + OfKeyword = 157, + QualifiedName = 158, + ComputedPropertyName = 159, + TypeParameter = 160, + Parameter = 161, + Decorator = 162, + PropertySignature = 163, + PropertyDeclaration = 164, + MethodSignature = 165, + MethodDeclaration = 166, + Constructor = 167, + GetAccessor = 168, + SetAccessor = 169, + CallSignature = 170, + ConstructSignature = 171, + IndexSignature = 172, + TypePredicate = 173, + TypeReference = 174, + FunctionType = 175, + ConstructorType = 176, + TypeQuery = 177, + TypeLiteral = 178, + ArrayType = 179, + TupleType = 180, + OptionalType = 181, + RestType = 182, + UnionType = 183, + IntersectionType = 184, + ConditionalType = 185, + InferType = 186, + ParenthesizedType = 187, + ThisType = 188, + TypeOperator = 189, + IndexedAccessType = 190, + MappedType = 191, + LiteralType = 192, + NamedTupleMember = 193, + TemplateLiteralType = 194, + TemplateLiteralTypeSpan = 195, + ImportType = 196, + ObjectBindingPattern = 197, + ArrayBindingPattern = 198, + BindingElement = 199, + ArrayLiteralExpression = 200, + ObjectLiteralExpression = 201, + PropertyAccessExpression = 202, + ElementAccessExpression = 203, + CallExpression = 204, + NewExpression = 205, + TaggedTemplateExpression = 206, + TypeAssertionExpression = 207, + ParenthesizedExpression = 208, + FunctionExpression = 209, + ArrowFunction = 210, + DeleteExpression = 211, + TypeOfExpression = 212, + VoidExpression = 213, + AwaitExpression = 214, + PrefixUnaryExpression = 215, + PostfixUnaryExpression = 216, + BinaryExpression = 217, + ConditionalExpression = 218, + TemplateExpression = 219, + YieldExpression = 220, + SpreadElement = 221, + ClassExpression = 222, + OmittedExpression = 223, + ExpressionWithTypeArguments = 224, + AsExpression = 225, + NonNullExpression = 226, + MetaProperty = 227, + SyntheticExpression = 228, + TemplateSpan = 229, + SemicolonClassElement = 230, + Block = 231, + EmptyStatement = 232, + VariableStatement = 233, + ExpressionStatement = 234, + IfStatement = 235, + DoStatement = 236, + WhileStatement = 237, + ForStatement = 238, + ForInStatement = 239, + ForOfStatement = 240, + ContinueStatement = 241, + BreakStatement = 242, + ReturnStatement = 243, + WithStatement = 244, + SwitchStatement = 245, + LabeledStatement = 246, + ThrowStatement = 247, + TryStatement = 248, + DebuggerStatement = 249, + VariableDeclaration = 250, + VariableDeclarationList = 251, + FunctionDeclaration = 252, + ClassDeclaration = 253, + InterfaceDeclaration = 254, + TypeAliasDeclaration = 255, + EnumDeclaration = 256, + ModuleDeclaration = 257, + ModuleBlock = 258, + CaseBlock = 259, + NamespaceExportDeclaration = 260, + ImportEqualsDeclaration = 261, + ImportDeclaration = 262, + ImportClause = 263, + NamespaceImport = 264, + NamedImports = 265, + ImportSpecifier = 266, + ExportAssignment = 267, + ExportDeclaration = 268, + NamedExports = 269, + NamespaceExport = 270, + ExportSpecifier = 271, + MissingDeclaration = 272, + ExternalModuleReference = 273, + JsxElement = 274, + JsxSelfClosingElement = 275, + JsxOpeningElement = 276, + JsxClosingElement = 277, + JsxFragment = 278, + JsxOpeningFragment = 279, + JsxClosingFragment = 280, + JsxAttribute = 281, + JsxAttributes = 282, + JsxSpreadAttribute = 283, + JsxExpression = 284, + CaseClause = 285, + DefaultClause = 286, + HeritageClause = 287, + CatchClause = 288, + PropertyAssignment = 289, + ShorthandPropertyAssignment = 290, + SpreadAssignment = 291, + EnumMember = 292, + UnparsedPrologue = 293, + UnparsedPrepend = 294, + UnparsedText = 295, + UnparsedInternalText = 296, + UnparsedSyntheticReference = 297, + SourceFile = 298, + Bundle = 299, + UnparsedSource = 300, + InputFiles = 301, + JSDocTypeExpression = 302, + JSDocNameReference = 303, + JSDocAllType = 304, + JSDocUnknownType = 305, + JSDocNullableType = 306, + JSDocNonNullableType = 307, + JSDocOptionalType = 308, + JSDocFunctionType = 309, + JSDocVariadicType = 310, + JSDocNamepathType = 311, + JSDocComment = 312, + JSDocText = 313, + JSDocTypeLiteral = 314, + JSDocSignature = 315, + JSDocLink = 316, + JSDocTag = 317, + JSDocAugmentsTag = 318, + JSDocImplementsTag = 319, + JSDocAuthorTag = 320, + JSDocDeprecatedTag = 321, + JSDocClassTag = 322, + JSDocPublicTag = 323, + JSDocPrivateTag = 324, + JSDocProtectedTag = 325, + JSDocReadonlyTag = 326, + JSDocOverrideTag = 327, + JSDocCallbackTag = 328, + JSDocEnumTag = 329, + JSDocParameterTag = 330, + JSDocReturnTag = 331, + JSDocThisTag = 332, + JSDocTypeTag = 333, + JSDocTemplateTag = 334, + JSDocTypedefTag = 335, + JSDocSeeTag = 336, + JSDocPropertyTag = 337, + SyntaxList = 338, + NotEmittedStatement = 339, + PartiallyEmittedExpression = 340, + CommaListExpression = 341, + MergeDeclarationMarker = 342, + EndOfDeclarationMarker = 343, + SyntheticReferenceExpression = 344, + Count = 345, FirstAssignment = 62, LastAssignment = 77, FirstCompoundAssignment = 63, @@ -453,15 +457,15 @@ declare namespace ts { FirstReservedWord = 80, LastReservedWord = 115, FirstKeyword = 80, - LastKeyword = 156, + LastKeyword = 157, FirstFutureReservedWord = 116, LastFutureReservedWord = 124, - FirstTypeNode = 172, - LastTypeNode = 195, + FirstTypeNode = 173, + LastTypeNode = 196, FirstPunctuation = 18, LastPunctuation = 77, FirstToken = 0, - LastToken = 156, + LastToken = 157, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -470,20 +474,20 @@ declare namespace ts { LastTemplateToken = 17, FirstBinaryOperator = 29, LastBinaryOperator = 77, - FirstStatement = 232, - LastStatement = 248, - FirstNode = 157, - FirstJSDocNode = 301, - LastJSDocNode = 333, - FirstJSDocTagNode = 314, - LastJSDocTagNode = 333, + FirstStatement = 233, + LastStatement = 249, + FirstNode = 158, + FirstJSDocNode = 302, + LastJSDocNode = 337, + FirstJSDocTagNode = 317, + LastJSDocTagNode = 337, } export type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; export type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; export type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; export type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; - export type 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.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.StaticKeyword; + export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; + export type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; export type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; export type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind; export type JsxTokenSyntaxKind = SyntaxKind.LessThanSlashToken | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; @@ -533,13 +537,14 @@ declare namespace ts { Const = 2048, HasComputedJSDocModifiers = 4096, Deprecated = 8192, + Override = 16384, HasComputedFlags = 536870912, AccessibilityModifier = 28, - ParameterPropertyModifier = 92, + ParameterPropertyModifier = 16476, NonPublicAccessibilityModifier = 24, - TypeScriptModifier = 2270, + TypeScriptModifier = 18654, ExportDefault = 513, - All = 11263 + All = 27647 } export enum JsxFlags { None = 0, @@ -558,7 +563,7 @@ declare namespace ts { } export interface JSDocContainer { } - export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken; + export type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | EmptyStatement | DebuggerStatement | Block | VariableStatement | ExpressionStatement | IfStatement | DoStatement | WhileStatement | ForStatement | ForInStatement | ForOfStatement | BreakStatement | ContinueStatement | ReturnStatement | WithStatement | SwitchStatement | LabeledStatement | ThrowStatement | TryStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | VariableDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | NamespaceExportDeclaration | ExportAssignment | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | ExportDeclaration | NamedTupleMember | EndOfFileToken; export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement; export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; @@ -603,10 +608,11 @@ declare namespace ts { export type ProtectedKeyword = ModifierToken; export type PublicKeyword = ModifierToken; export type ReadonlyKeyword = ModifierToken; + export type OverrideKeyword = ModifierToken; export type StaticKeyword = ModifierToken; /** @deprecated Use `ReadonlyKeyword` instead. */ export type ReadonlyToken = ReadonlyKeyword; - export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | ReadonlyKeyword | StaticKeyword; + export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword; export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword; export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword; @@ -638,6 +644,7 @@ declare namespace ts { } export type EntityName = Identifier | QualifiedName; export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName | PrivateIdentifier; + export type MemberName = Identifier | PrivateIdentifier; export type DeclarationName = Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; export interface Declaration extends Node { _declarationBrand: any; @@ -686,7 +693,7 @@ declare namespace ts { readonly kind: SyntaxKind.ConstructSignature; } export type BindingName = Identifier | BindingPattern; - export interface VariableDeclaration extends NamedDeclaration { + export interface VariableDeclaration extends NamedDeclaration, JSDocContainer { readonly kind: SyntaxKind.VariableDeclaration; readonly parent: VariableDeclarationList | CatchClause; readonly name: BindingName; @@ -820,15 +827,15 @@ declare namespace ts { readonly kind: SyntaxKind.SemicolonClassElement; readonly parent: ClassLikeDeclaration; } - export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.GetAccessor; - readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; readonly name: PropertyName; readonly body?: FunctionBody; } - export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { + export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.SetAccessor; - readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; readonly name: PropertyName; readonly body?: FunctionBody; } @@ -1216,11 +1223,11 @@ declare namespace ts { readonly kind: SyntaxKind.PropertyAccessExpression; readonly expression: LeftHandSideExpression; readonly questionDotToken?: QuestionDotToken; - readonly name: Identifier | PrivateIdentifier; + readonly name: MemberName; } export interface PropertyAccessChain extends PropertyAccessExpression { _optionalChainBrand: any; - readonly name: Identifier | PrivateIdentifier; + readonly name: MemberName; } export interface SuperPropertyAccessExpression extends PropertyAccessExpression { readonly expression: SuperExpression; @@ -1373,7 +1380,7 @@ declare namespace ts { readonly containsOnlyTriviaWhiteSpaces: boolean; } export type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; - export interface Statement extends Node { + export interface Statement extends Node, JSDocContainer { _statementBrand: any; } export interface NotEmittedStatement extends Statement { @@ -1401,11 +1408,11 @@ declare namespace ts { readonly kind: SyntaxKind.Block; readonly statements: NodeArray; } - export interface VariableStatement extends Statement, JSDocContainer { + export interface VariableStatement extends Statement { readonly kind: SyntaxKind.VariableStatement; readonly declarationList: VariableDeclarationList; } - export interface ExpressionStatement extends Statement, JSDocContainer { + export interface ExpressionStatement extends Statement { readonly kind: SyntaxKind.ExpressionStatement; readonly expression: Expression; } @@ -1486,7 +1493,7 @@ declare namespace ts { readonly statements: NodeArray; } export type CaseOrDefaultClause = CaseClause | DefaultClause; - export interface LabeledStatement extends Statement, JSDocContainer { + export interface LabeledStatement extends Statement { readonly kind: SyntaxKind.LabeledStatement; readonly label: Identifier; readonly statement: Statement; @@ -1606,7 +1613,7 @@ declare namespace ts { readonly parent: ImportEqualsDeclaration; readonly expression: Expression; } - export interface ImportDeclaration extends Statement, JSDocContainer { + export interface ImportDeclaration extends Statement { readonly kind: SyntaxKind.ImportDeclaration; readonly parent: SourceFile | ModuleBlock; readonly importClause?: ImportClause; @@ -1742,12 +1749,21 @@ declare namespace ts { readonly kind: SyntaxKind.JSDocComment; readonly parent: HasJSDoc; readonly tags?: NodeArray; - readonly comment?: string; + readonly comment?: string | NodeArray; } export interface JSDocTag extends Node { readonly parent: JSDoc | JSDocTypeLiteral; readonly tagName: Identifier; - readonly comment?: string; + readonly comment?: string | NodeArray; + } + export interface JSDocLink extends Node { + readonly kind: SyntaxKind.JSDocLink; + readonly name?: EntityName; + text: string; + } + export interface JSDocText extends Node { + readonly kind: SyntaxKind.JSDocText; + text: string; } export interface JSDocUnknownTag extends JSDocTag { readonly kind: SyntaxKind.JSDocTag; @@ -1789,6 +1805,9 @@ declare namespace ts { export interface JSDocReadonlyTag extends JSDocTag { readonly kind: SyntaxKind.JSDocReadonlyTag; } + export interface JSDocOverrideTag extends JSDocTag { + readonly kind: SyntaxKind.JSDocOverrideTag; + } export interface JSDocEnumTag extends JSDocTag, Declaration { readonly kind: SyntaxKind.JSDocEnumTag; readonly parent: JSDoc; @@ -2080,7 +2099,6 @@ declare namespace ts { * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; - getTypeCatalog(): readonly Type[]; getNodeCount(): number; getIdentifierCount(): number; getSymbolCount(): number; @@ -2186,7 +2204,7 @@ declare namespace ts { * The function returns the value (local variable) symbol of an identifier in the short-hand property assignment. * This is necessary as an identifier in short-hand property assignment can contains two meaning: property name and property value. */ - getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; + getShorthandAssignmentValueSymbol(location: Node | undefined): Symbol | undefined; getExportSpecifierLocalTargetSymbol(location: ExportSpecifier | Identifier): Symbol | undefined; /** * If a symbol is a local symbol with an associated exported symbol, returns the exported symbol. @@ -2261,6 +2279,8 @@ declare namespace ts { NoTypeReduction = 536870912, NoUndefinedOptionalParameterType = 1073741824, AllowThisInObjectLiteral = 32768, + AllowQualifiedNameInPlaceOfIdentifier = 65536, + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ AllowQualifedNameInPlaceOfIdentifier = 65536, AllowAnonymousIdentifier = 131072, AllowEmptyUnionOrIntersection = 262144, @@ -2271,8 +2291,7 @@ declare namespace ts { IgnoreErrors = 70221824, InObjectTypeLiteral = 4194304, InTypeAlias = 8388608, - InInitialEntityName = 16777216, - InReverseMappedType = 33554432 + InInitialEntityName = 16777216 } export enum TypeFormatFlags { None = 0, @@ -2405,8 +2424,8 @@ declare namespace ts { export interface Symbol { flags: SymbolFlags; escapedName: __String; - declarations: Declaration[]; - valueDeclaration: Declaration; + declarations?: Declaration[]; + valueDeclaration?: Declaration; members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; @@ -2540,15 +2559,15 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, - ContainsSpread = 1024, - ReverseMapped = 2048, - JsxAttributes = 4096, - MarkerType = 8192, - JSLiteral = 16384, - FreshLiteral = 32768, - ArrayLiteral = 65536, - ObjectRestType = 131072, + ReverseMapped = 1024, + JsxAttributes = 2048, + MarkerType = 4096, + JSLiteral = 8192, + FreshLiteral = 16384, + ArrayLiteral = 32768, ClassOrInterface = 3, + ContainsSpread = 4194304, + ObjectRestType = 8388608, } export interface ObjectType extends Type { objectFlags: ObjectFlags; @@ -2662,6 +2681,7 @@ declare namespace ts { type: Type; } export interface SubstitutionType extends InstantiableType { + objectFlags: ObjectFlags; baseType: Type; substitute: Type; } @@ -2686,16 +2706,17 @@ declare namespace ts { export enum InferencePriority { NakedTypeVariable = 1, SpeculativeTuple = 2, - HomomorphicMappedType = 4, - PartialHomomorphicMappedType = 8, - MappedTypeConstraint = 16, - ContravariantConditional = 32, - ReturnType = 64, - LiteralKeyof = 128, - NoConstraints = 256, - AlwaysStrict = 512, - MaxValue = 1024, - PriorityImpliesCombination = 208, + SubstituteSource = 4, + HomomorphicMappedType = 8, + PartialHomomorphicMappedType = 16, + MappedTypeConstraint = 32, + ContravariantConditional = 64, + ReturnType = 128, + LiteralKeyof = 256, + NoConstraints = 512, + AlwaysStrict = 1024, + MaxValue = 2048, + PriorityImpliesCombination = 416, Circularity = -1 } /** @deprecated Use FileExtensionInfo instead. */ @@ -2772,18 +2793,21 @@ declare namespace ts { FixedPollingInterval = 0, PriorityPollingInterval = 1, DynamicPriorityPolling = 2, - UseFsEvents = 3, - UseFsEventsOnParentDirectory = 4 + FixedChunkSizePolling = 3, + UseFsEvents = 4, + UseFsEventsOnParentDirectory = 5 } export enum WatchDirectoryKind { UseFsEvents = 0, FixedPollingInterval = 1, - DynamicPriorityPolling = 2 + DynamicPriorityPolling = 2, + FixedChunkSizePolling = 3 } export enum PollingWatchKind { FixedInterval = 0, PriorityInterval = 1, - DynamicPriority = 2 + DynamicPriority = 2, + FixedChunkSize = 3 } export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; export interface CompilerOptions { @@ -2845,6 +2869,7 @@ declare namespace ts { outFile?: string; paths?: MapLike; preserveConstEnums?: boolean; + noImplicitOverride?: boolean; preserveSymlinks?: boolean; project?: string; reactNamespace?: string; @@ -2955,6 +2980,7 @@ declare namespace ts { ES2018 = 5, ES2019 = 6, ES2020 = 7, + ES2021 = 8, ESNext = 99, JSON = 100, Latest = 99 @@ -3128,17 +3154,21 @@ declare namespace ts { Iterator = 8388608, NoAsciiEscaping = 16777216, } - export interface EmitHelper { + export interface EmitHelperBase { readonly name: string; readonly scoped: boolean; readonly text: string | ((node: EmitHelperUniqueNameCallback) => string); readonly priority?: number; readonly dependencies?: EmitHelper[]; } - export interface UnscopedEmitHelper extends EmitHelper { + export interface ScopedEmitHelper extends EmitHelperBase { + readonly scoped: true; + } + export interface UnscopedEmitHelper extends EmitHelperBase { readonly scoped: false; readonly text: string; } + export type EmitHelper = ScopedEmitHelper | UnscopedEmitHelper; export type EmitHelperUniqueNameCallback = (name: string) => string; export enum EmitHint { SourceFile = 0, @@ -3166,14 +3196,27 @@ declare namespace ts { createStringLiteralFromNode(sourceNode: PropertyNameLiteral, isSingleQuote?: boolean): StringLiteral; createRegularExpressionLiteral(text: string): RegularExpressionLiteral; createIdentifier(text: string): Identifier; - /** Create a unique temporary variable. */ - createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; - /** Create a unique temporary variable for use in a loop. */ - createLoopVariable(): Identifier; + /** + * Create a unique temporary variable. + * @param recordTempVariable An optional callback used to record the temporary variable name. This + * should usually be a reference to `hoistVariableDeclaration` from a `TransformationContext`, but + * can be `undefined` if you plan to record the temporary variable manually. + * @param reservedInNestedScopes When `true`, reserves the temporary variable name in all nested scopes + * during emit so that the variable can be referenced in a nested function body. This is an alternative to + * setting `EmitFlags.ReuseTempVariableScope` on the nested function itself. + */ + createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes?: boolean): Identifier; + /** + * Create a unique temporary variable for use in a loop. + * @param reservedInNestedScopes When `true`, reserves the temporary variable name in all nested scopes + * during emit so that the variable can be referenced in a nested function body. This is an alternative to + * setting `EmitFlags.ReuseTempVariableScope` on the nested function itself. + */ + createLoopVariable(reservedInNestedScopes?: boolean): Identifier; /** Create a unique name based on the supplied text. */ createUniqueName(text: string, flags?: GeneratedIdentifierFlags): Identifier; /** Create a unique name generated for a node. */ - getGeneratedNameForNode(node: Node | undefined): Identifier; + getGeneratedNameForNode(node: Node | undefined, flags?: GeneratedIdentifierFlags): Identifier; createPrivateIdentifier(text: string): PrivateIdentifier; createToken(token: SyntaxKind.SuperKeyword): SuperExpression; createToken(token: SyntaxKind.ThisKeyword): ThisExpression; @@ -3284,10 +3327,10 @@ declare namespace ts { updateArrayLiteralExpression(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; createObjectLiteralExpression(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; updateObjectLiteralExpression(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; - createPropertyAccessExpression(expression: Expression, name: string | Identifier | PrivateIdentifier): PropertyAccessExpression; - updatePropertyAccessExpression(node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier): PropertyAccessExpression; - createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier | PrivateIdentifier): PropertyAccessChain; - updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier | PrivateIdentifier): PropertyAccessChain; + createPropertyAccessExpression(expression: Expression, name: string | MemberName): PropertyAccessExpression; + updatePropertyAccessExpression(node: PropertyAccessExpression, expression: Expression, name: MemberName): PropertyAccessExpression; + createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | MemberName): PropertyAccessChain; + updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: MemberName): PropertyAccessChain; createElementAccessExpression(expression: Expression, index: number | Expression): ElementAccessExpression; updateElementAccessExpression(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; @@ -3455,52 +3498,58 @@ declare namespace ts { updateJSDocTypeExpression(node: JSDocTypeExpression, type: TypeNode): JSDocTypeExpression; createJSDocNameReference(name: EntityName): JSDocNameReference; updateJSDocNameReference(node: JSDocNameReference, name: EntityName): JSDocNameReference; + createJSDocLink(name: EntityName | undefined, text: string): JSDocLink; + updateJSDocLink(node: JSDocLink, name: EntityName | undefined, text: string): JSDocLink; createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral; updateJSDocTypeLiteral(node: JSDocTypeLiteral, jsDocPropertyTags: readonly JSDocPropertyLikeTag[] | undefined, isArrayType: boolean | undefined): JSDocTypeLiteral; createJSDocSignature(typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag): JSDocSignature; updateJSDocSignature(node: JSDocSignature, typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type: JSDocReturnTag | undefined): JSDocSignature; - createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string): JSDocTemplateTag; - updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | undefined): JSDocTemplateTag; - createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string): JSDocTypedefTag; - updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | undefined): JSDocTypedefTag; - createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocParameterTag; - updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | undefined): JSDocParameterTag; - createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string): JSDocPropertyTag; - updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | undefined): JSDocPropertyTag; - createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocTypeTag; - updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | undefined): JSDocTypeTag; - createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string): JSDocSeeTag; - updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string): JSDocSeeTag; - createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string): JSDocReturnTag; - updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | undefined): JSDocReturnTag; - createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocThisTag; - updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | undefined): JSDocThisTag; - createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string): JSDocEnumTag; - updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | undefined): JSDocEnumTag; - createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string): JSDocCallbackTag; - updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | undefined): JSDocCallbackTag; - createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string): JSDocAugmentsTag; - updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | undefined): JSDocAugmentsTag; - createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string): JSDocImplementsTag; - updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | undefined): JSDocImplementsTag; - createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string): JSDocAuthorTag; - updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | undefined): JSDocAuthorTag; - createJSDocClassTag(tagName: Identifier | undefined, comment?: string): JSDocClassTag; - updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | undefined): JSDocClassTag; - createJSDocPublicTag(tagName: Identifier | undefined, comment?: string): JSDocPublicTag; - updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | undefined): JSDocPublicTag; - createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string): JSDocPrivateTag; - updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | undefined): JSDocPrivateTag; - createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string): JSDocProtectedTag; - updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | undefined): JSDocProtectedTag; - createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string): JSDocReadonlyTag; - updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | undefined): JSDocReadonlyTag; - createJSDocUnknownTag(tagName: Identifier, comment?: string): JSDocUnknownTag; - updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | undefined): JSDocUnknownTag; - createJSDocDeprecatedTag(tagName: Identifier, comment?: string): JSDocDeprecatedTag; - updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string): JSDocDeprecatedTag; - createJSDocComment(comment?: string | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; - updateJSDocComment(node: JSDoc, comment: string | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; + createJSDocTemplateTag(tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray): JSDocTemplateTag; + updateJSDocTemplateTag(node: JSDocTemplateTag, tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment: string | NodeArray | undefined): JSDocTemplateTag; + createJSDocTypedefTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | JSDocTypeLiteral, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocTypedefTag; + updateJSDocTypedefTag(node: JSDocTypedefTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | JSDocTypeLiteral | undefined, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocTypedefTag; + createJSDocParameterTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocParameterTag; + updateJSDocParameterTag(node: JSDocParameterTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocParameterTag; + createJSDocPropertyTag(tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression, isNameFirst?: boolean, comment?: string | NodeArray): JSDocPropertyTag; + updateJSDocPropertyTag(node: JSDocPropertyTag, tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression: JSDocTypeExpression | undefined, isNameFirst: boolean, comment: string | NodeArray | undefined): JSDocPropertyTag; + createJSDocTypeTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocTypeTag; + updateJSDocTypeTag(node: JSDocTypeTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocTypeTag; + createJSDocSeeTag(tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; + updateJSDocSeeTag(node: JSDocSeeTag, tagName: Identifier | undefined, nameExpression: JSDocNameReference | undefined, comment?: string | NodeArray): JSDocSeeTag; + createJSDocReturnTag(tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression, comment?: string | NodeArray): JSDocReturnTag; + updateJSDocReturnTag(node: JSDocReturnTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocReturnTag; + createJSDocThisTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocThisTag; + updateJSDocThisTag(node: JSDocThisTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression | undefined, comment: string | NodeArray | undefined): JSDocThisTag; + createJSDocEnumTag(tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray): JSDocEnumTag; + updateJSDocEnumTag(node: JSDocEnumTag, tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment: string | NodeArray | undefined): JSDocEnumTag; + createJSDocCallbackTag(tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration, comment?: string | NodeArray): JSDocCallbackTag; + updateJSDocCallbackTag(node: JSDocCallbackTag, tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName: Identifier | JSDocNamespaceDeclaration | undefined, comment: string | NodeArray | undefined): JSDocCallbackTag; + createJSDocAugmentsTag(tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment?: string | NodeArray): JSDocAugmentsTag; + updateJSDocAugmentsTag(node: JSDocAugmentsTag, tagName: Identifier | undefined, className: JSDocAugmentsTag["class"], comment: string | NodeArray | undefined): JSDocAugmentsTag; + createJSDocImplementsTag(tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment?: string | NodeArray): JSDocImplementsTag; + updateJSDocImplementsTag(node: JSDocImplementsTag, tagName: Identifier | undefined, className: JSDocImplementsTag["class"], comment: string | NodeArray | undefined): JSDocImplementsTag; + createJSDocAuthorTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocAuthorTag; + updateJSDocAuthorTag(node: JSDocAuthorTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocAuthorTag; + createJSDocClassTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocClassTag; + updateJSDocClassTag(node: JSDocClassTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocClassTag; + createJSDocPublicTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPublicTag; + updateJSDocPublicTag(node: JSDocPublicTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPublicTag; + createJSDocPrivateTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocPrivateTag; + updateJSDocPrivateTag(node: JSDocPrivateTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocPrivateTag; + createJSDocProtectedTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocProtectedTag; + updateJSDocProtectedTag(node: JSDocProtectedTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocProtectedTag; + createJSDocReadonlyTag(tagName: Identifier | undefined, comment?: string | NodeArray): JSDocReadonlyTag; + updateJSDocReadonlyTag(node: JSDocReadonlyTag, tagName: Identifier | undefined, comment: string | NodeArray | undefined): JSDocReadonlyTag; + createJSDocUnknownTag(tagName: Identifier, comment?: string | NodeArray): JSDocUnknownTag; + updateJSDocUnknownTag(node: JSDocUnknownTag, tagName: Identifier, comment: string | NodeArray | undefined): JSDocUnknownTag; + createJSDocDeprecatedTag(tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + updateJSDocDeprecatedTag(node: JSDocDeprecatedTag, tagName: Identifier, comment?: string | NodeArray): JSDocDeprecatedTag; + createJSDocOverrideTag(tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + updateJSDocOverrideTag(node: JSDocOverrideTag, tagName: Identifier, comment?: string | NodeArray): JSDocOverrideTag; + createJSDocText(text: string): JSDocText; + updateJSDocText(node: JSDocText, text: string): JSDocText; + createJSDocComment(comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined): JSDoc; + updateJSDocComment(node: JSDoc, comment: string | NodeArray | undefined, tags: readonly JSDocTag[] | undefined): JSDoc; createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; @@ -3748,12 +3797,12 @@ declare namespace ts { * }); * ``` */ - onEmitNode?(hint: EmitHint, node: Node | undefined, emitCallback: (hint: EmitHint, node: Node | undefined) => void): void; + onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; /** * A hook used to check if an emit notification is required for a node. * @param node The node to emit. */ - isEmitNotificationEnabled?(node: Node | undefined): boolean; + isEmitNotificationEnabled?(node: Node): boolean; /** * A hook used by the Printer to perform just-in-time substitution of a node. This is * primarily used by node transformations that need to substitute one node for another, @@ -3867,6 +3916,8 @@ declare namespace ts { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; + readonly includeCompletionsForImportStatements?: boolean; + readonly includeCompletionsWithSnippetText?: boolean; readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "shortest" | "project-relative" | "relative" | "non-relative"; @@ -3965,7 +4016,7 @@ declare namespace ts { scanJsxIdentifier(): SyntaxKind; scanJsxAttributeValue(): SyntaxKind; reScanJsxAttributeValue(): SyntaxKind; - reScanJsxToken(): JsxTokenSyntaxKind; + reScanJsxToken(allowMultilineJsxText?: boolean): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; reScanQuestionToken(): SyntaxKind; reScanInvalidIdentifier(): SyntaxKind; @@ -4100,7 +4151,7 @@ declare namespace ts { function idText(identifierOrPrivateName: Identifier | PrivateIdentifier): string; function symbolName(symbol: Symbol): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression | undefined): DeclarationName | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -4146,6 +4197,7 @@ declare namespace ts { function getJSDocProtectedTag(node: Node): JSDocProtectedTag | undefined; /** Gets the JSDoc protected tag for the node if present */ function getJSDocReadonlyTag(node: Node): JSDocReadonlyTag | undefined; + function getJSDocOverrideTagNoCache(node: Node): JSDocOverrideTag | undefined; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node: Node): JSDocDeprecatedTag | undefined; /** Gets the JSDoc enum tag for the node if present */ @@ -4183,13 +4235,15 @@ declare namespace ts { function getAllJSDocTags(node: Node, predicate: (tag: JSDocTag) => tag is T): readonly T[]; /** Gets all JSDoc tags of a specified kind */ function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; + /** Gets the text of a jsdoc comment, flattening links to their text. */ + function getTextOfJSDocComment(comment?: string | NodeArray): string | undefined; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. */ function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; - function isIdentifierOrPrivateIdentifier(node: Node): node is Identifier | PrivateIdentifier; + function isMemberName(node: Node): node is MemberName; function isPropertyAccessChain(node: Node): node is PropertyAccessChain; function isElementAccessChain(node: Node): node is ElementAccessChain; function isCallChain(node: Node): node is CallChain; @@ -4204,6 +4258,12 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag; + /** + * True if kind is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. + */ + function isTokenKind(kind: SyntaxKind): boolean; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. @@ -4220,7 +4280,7 @@ declare namespace ts { function isEntityName(node: Node): node is EntityName; function isPropertyName(node: Node): node is PropertyName; function isBindingName(node: Node): node is BindingName; - function isFunctionLike(node: Node): node is SignatureDeclaration; + function isFunctionLike(node: Node | undefined): node is SignatureDeclaration; function isClassElement(node: Node): node is ClassElement; function isClassLike(node: Node): node is ClassLikeDeclaration; function isAccessor(node: Node): node is AccessorDeclaration; @@ -4346,10 +4406,14 @@ declare namespace ts { function isTemplateHead(node: Node): node is TemplateHead; function isTemplateMiddle(node: Node): node is TemplateMiddle; function isTemplateTail(node: Node): node is TemplateTail; + function isDotDotDotToken(node: Node): node is DotDotDotToken; + function isPlusToken(node: Node): node is PlusToken; + function isMinusToken(node: Node): node is MinusToken; + function isAsteriskToken(node: Node): node is AsteriskToken; function isIdentifier(node: Node): node is Identifier; + function isPrivateIdentifier(node: Node): node is PrivateIdentifier; function isQualifiedName(node: Node): node is QualifiedName; function isComputedPropertyName(node: Node): node is ComputedPropertyName; - function isPrivateIdentifier(node: Node): node is PrivateIdentifier; function isTypeParameterDeclaration(node: Node): node is TypeParameterDeclaration; function isParameter(node: Node): node is ParameterDeclaration; function isDecorator(node: Node): node is Decorator; @@ -4492,6 +4556,7 @@ declare namespace ts { function isUnparsedSource(node: Node): node is UnparsedSource; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; function isJSDocNameReference(node: Node): node is JSDocNameReference; + function isJSDocLink(node: Node): node is JSDocLink; function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; @@ -4511,6 +4576,7 @@ declare namespace ts { function isJSDocPrivateTag(node: Node): node is JSDocPrivateTag; function isJSDocProtectedTag(node: Node): node is JSDocProtectedTag; function isJSDocReadonlyTag(node: Node): node is JSDocReadonlyTag; + function isJSDocOverrideTag(node: Node): node is JSDocOverrideTag; function isJSDocDeprecatedTag(node: Node): node is JSDocDeprecatedTag; function isJSDocSeeTag(node: Node): node is JSDocSeeTag; function isJSDocEnumTag(node: Node): node is JSDocEnumTag; @@ -4575,7 +4641,7 @@ declare namespace ts { /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[]): ParsedCommandLine | undefined; + export function getParsedCommandLineOfConfigFile(configFileName: string, optionsToExtend: CompilerOptions | undefined, host: ParseConfigFileHost, extendedConfigCache?: Map, watchOptionsToExtend?: WatchOptions, extraFileExtensions?: readonly FileExtensionInfo[]): ParsedCommandLine | undefined; /** * Read tsconfig.json file * @param fileName The path to the config file @@ -4643,13 +4709,13 @@ declare namespace ts { export {}; } declare namespace ts { - function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; + export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; /** * @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 * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, cache?: TypeReferenceDirectiveResolutionCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -4658,30 +4724,46 @@ declare namespace ts { * More type directives might appear in the program later as a result of loading actual source files; * this list is only the set of defaults that are implicitly included. */ - function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache, PackageJsonInfoCache { + } /** - * Cached module resolutions per containing directory. + * Cached resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ - interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { - getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + export interface PerDirectoryResolutionCache { + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + clear(): void; + /** + * Updates with the current compilerOptions the cache will operate with. + * This updates the redirects map as well if needed so module resolutions are cached if they can across the projects + */ + update(options: CompilerOptions): void; + } + export interface ModuleResolutionCache extends PerDirectoryResolutionCache, NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { + getPackageJsonInfoCache(): PackageJsonInfoCache; } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ - interface NonRelativeModuleNameResolutionCache { + export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache { getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } - interface PerModuleNameCache { + export interface PackageJsonInfoCache { + clear(): void; + } + export interface PerModuleNameCache { get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } - function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; - function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + 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 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 {}; } declare namespace ts { /** @@ -4748,6 +4830,10 @@ declare namespace ts { * environment and merging hoisted declarations upon completion. */ function visitFunctionBody(node: ConciseBody, visitor: Visitor, context: TransformationContext): ConciseBody; + /** + * Visits an iteration body, adding any block-scoped variables required by the transformation. + */ + function visitIterationBody(body: Statement, visitor: Visitor, context: TransformationContext): Statement; /** * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. * @@ -5036,6 +5122,8 @@ declare namespace ts { interface WatchCompilerHost extends ProgramHost, WatchHost { /** Instead of using output d.ts file from project reference, use its source file */ useSourceOfProjectReferenceRedirect?(): boolean; + /** If provided, use this method to get parsed command lines for referenced projects */ + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; /** If provided, callback to invoke after every new program creation */ afterProgramCreate?(program: T): void; } @@ -5131,9 +5219,9 @@ declare namespace ts { interface SolutionBuilderWithWatchHost extends SolutionBuilderHostBase, WatchHost { } interface SolutionBuilder { - build(project?: string, cancellationToken?: CancellationToken): ExitStatus; + build(project?: string, cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, getCustomTransformers?: (project: string) => CustomTransformers): ExitStatus; clean(project?: string): ExitStatus; - buildReferences(project: string, cancellationToken?: CancellationToken): ExitStatus; + buildReferences(project: string, cancellationToken?: CancellationToken, writeFile?: WriteFileCallback, getCustomTransformers?: (project: string) => CustomTransformers): ExitStatus; cleanReferences(project?: string): ExitStatus; getNextInvalidatedProject(cancellationToken?: CancellationToken): InvalidatedProject | undefined; } @@ -5291,7 +5379,7 @@ declare namespace ts { getName(): string; getDeclarations(): Declaration[] | undefined; getDocumentationComment(typeChecker: TypeChecker | undefined): SymbolDisplayPart[]; - getJsDocTags(): JSDocTagInfo[]; + getJsDocTags(checker?: TypeChecker): JSDocTagInfo[]; } interface Type { getFlags(): TypeFlags; @@ -5422,6 +5510,7 @@ declare namespace ts { isKnownTypesPackageName?(name: string): boolean; installPackage?(options: InstallPackageOptions): Promise; writeFile?(fileName: string, content: string): void; + getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined; } type WithMetadata = T & { metadata?: unknown; @@ -5511,12 +5600,13 @@ declare namespace ts { * * @param fileName The path to the file * @param position A zero based index of the character where you want the entries - * @param entryName The name from an existing completion which came from `getCompletionsAtPosition` + * @param entryName The `name` from an existing completion which came from `getCompletionsAtPosition` * @param formatOptions How should code samples in the completions be formatted, can be undefined for backwards compatibility - * @param source Source code for the current file, can be undefined for backwards compatibility + * @param source `source` property from the completion entry * @param preferences User settings, can be undefined for backwards compatibility + * @param data `data` property from the completion entry */ - getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined; + getCompletionEntryDetails(fileName: string, position: number, entryName: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined, data: CompletionEntryData | undefined): CompletionEntryDetails | undefined; getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined; /** * Gets semantic information about the identifier at a particular position in a @@ -5577,7 +5667,7 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined, triggerReason?: RefactorTriggerReason, kind?: string): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; - organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + organizeImports(args: OrganizeImportsArgs, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): EmitOutput; getProgram(): Program | undefined; @@ -5594,8 +5684,10 @@ declare namespace ts { type: "file"; fileName: string; } - type OrganizeImportsScope = CombinedCodeFixScope; - type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#"; + interface OrganizeImportsArgs extends CombinedCodeFixScope { + skipDestructiveCodeActions?: boolean; + } + type CompletionsTriggerCharacter = "." | '"' | "'" | "`" | "/" | "@" | "<" | "#" | " "; interface GetCompletionsAtPositionOptions extends UserPreferences { /** * If the editor is asking for completions because a certain character was typed @@ -5947,6 +6039,7 @@ declare namespace ts { name: string; containerKind: ScriptElementKind; containerName: string; + unverified?: boolean; } interface DefinitionInfoAndBoundSpan { definitions?: readonly DefinitionInfo[]; @@ -5981,15 +6074,21 @@ declare namespace ts { typeParameterName = 18, enumMemberName = 19, functionName = 20, - regularExpressionLiteral = 21 + regularExpressionLiteral = 21, + link = 22, + linkName = 23, + linkText = 24 } interface SymbolDisplayPart { text: string; kind: string; } + interface JSDocLinkDisplayPart extends SymbolDisplayPart { + target: DocumentSpan; + } interface JSDocTagInfo { name: string; - text?: string; + text?: SymbolDisplayPart[]; } interface QuickInfo { kind: ScriptElementKind; @@ -6074,14 +6173,36 @@ declare namespace ts { * true when the current location also allows for a new identifier */ isNewIdentifierLocation: boolean; + /** + * Indicates to client to continue requesting completions on subsequent keystrokes. + */ + 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; + /** + * 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; + } interface CompletionEntry { name: string; kind: ScriptElementKind; kindModifiers?: string; sortText: string; insertText?: string; + isSnippet?: true; /** * An optional span that indicates the text to be replaced by this completion item. * If present, this span should be used instead of the default one. @@ -6090,9 +6211,20 @@ declare namespace ts { replacementSpan?: TextSpan; hasAction?: true; source?: string; + sourceDisplay?: SymbolDisplayPart[]; isRecommended?: true; isFromUncheckedFile?: true; isPackageJsonImport?: true; + isImportStatementCompletion?: true; + /** + * A property to be sent back to TS Server in the CompletionDetailsRequest, along with `name`, + * that allows TS Server to look up the symbol represented by the completion item, disambiguating + * items with the same name. Currently only defined for auto-import completions, but the type is + * `unknown` in the protocol, so it can be changed as needed to support other kinds of completions. + * The presence of this property should generally not be used to assume that this completion entry + * is an auto-import. + */ + data?: CompletionEntryData; } interface CompletionEntryDetails { name: string; @@ -6102,7 +6234,9 @@ declare namespace ts { documentation?: SymbolDisplayPart[]; tags?: JSDocTagInfo[]; codeActions?: CodeAction[]; + /** @deprecated Use `sourceDisplay` instead. */ source?: SymbolDisplayPart[]; + sourceDisplay?: SymbolDisplayPart[]; } interface OutliningSpan { /** The span of the document to actually collapse. */ @@ -6256,7 +6390,13 @@ declare namespace ts { */ jsxAttribute = "JSX attribute", /** String literal */ - string = "string" + string = "string", + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + link = "link", + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + linkName = "link name", + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + linkText = "link text" } enum ScriptElementKindModifier { none = "", @@ -6397,8 +6537,23 @@ declare namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file */ + /**@deprecated pass scriptKind for correctness */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + /** + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @param fileName The name of the file to be released + * @param compilationSettings The compilation settings used to acquire the file + * @param scriptKind The script kind of the file to be released + */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; + /** + * @deprecated pass scriptKind for correctness */ releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; reportStats(): string; } type DocumentRegistryBucketKey = string & { @@ -6469,7 +6624,7 @@ declare namespace ts { /** @deprecated Use `factory.createRegularExpressionLiteral` or the factory supplied by your transformation context instead. */ const createRegularExpressionLiteral: (text: string) => RegularExpressionLiteral; /** @deprecated Use `factory.createLoopVariable` or the factory supplied by your transformation context instead. */ - const createLoopVariable: () => Identifier; + const createLoopVariable: (reservedInNestedScopes?: boolean | undefined) => Identifier; /** @deprecated Use `factory.createUniqueName` or the factory supplied by your transformation context instead. */ const createUniqueName: (text: string, flags?: GeneratedIdentifierFlags | undefined) => Identifier; /** @deprecated Use `factory.createPrivateIdentifier` or the factory supplied by your transformation context instead. */ @@ -6641,13 +6796,13 @@ declare namespace ts { /** @deprecated Use `factory.updateObjectLiteralExpression` or the factory supplied by your transformation context instead. */ const updateObjectLiteral: (node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]) => ObjectLiteralExpression; /** @deprecated Use `factory.createPropertyAccessExpression` or the factory supplied by your transformation context instead. */ - const createPropertyAccess: (expression: Expression, name: string | Identifier | PrivateIdentifier) => PropertyAccessExpression; + const createPropertyAccess: (expression: Expression, name: string | MemberName) => PropertyAccessExpression; /** @deprecated Use `factory.updatePropertyAccessExpression` or the factory supplied by your transformation context instead. */ - const updatePropertyAccess: (node: PropertyAccessExpression, expression: Expression, name: Identifier | PrivateIdentifier) => PropertyAccessExpression; + const updatePropertyAccess: (node: PropertyAccessExpression, expression: Expression, name: MemberName) => PropertyAccessExpression; /** @deprecated Use `factory.createPropertyAccessChain` or the factory supplied by your transformation context instead. */ - const createPropertyAccessChain: (expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier | PrivateIdentifier) => PropertyAccessChain; + const createPropertyAccessChain: (expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | MemberName) => PropertyAccessChain; /** @deprecated Use `factory.updatePropertyAccessChain` or the factory supplied by your transformation context instead. */ - const updatePropertyAccessChain: (node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier | PrivateIdentifier) => PropertyAccessChain; + const updatePropertyAccessChain: (node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: MemberName) => PropertyAccessChain; /** @deprecated Use `factory.createElementAccessExpression` or the factory supplied by your transformation context instead. */ const createElementAccess: (expression: Expression, index: number | Expression) => ElementAccessExpression; /** @deprecated Use `factory.updateElementAccessExpression` or the factory supplied by your transformation context instead. */ @@ -6917,51 +7072,51 @@ declare namespace ts { /** @deprecated Use `factory.createJSDocTypeExpression` or the factory supplied by your transformation context instead. */ const createJSDocTypeExpression: (type: TypeNode) => JSDocTypeExpression; /** @deprecated Use `factory.createJSDocTypeTag` or the factory supplied by your transformation context instead. */ - const createJSDocTypeTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocTypeTag; + const createJSDocTypeTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocTypeTag; /** @deprecated Use `factory.createJSDocReturnTag` or the factory supplied by your transformation context instead. */ - const createJSDocReturnTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | undefined, comment?: string | undefined) => JSDocReturnTag; + const createJSDocReturnTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeExpression | undefined, comment?: string | NodeArray | undefined) => JSDocReturnTag; /** @deprecated Use `factory.createJSDocThisTag` or the factory supplied by your transformation context instead. */ - const createJSDocThisTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocThisTag; + const createJSDocThisTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocThisTag; /** @deprecated Use `factory.createJSDocComment` or the factory supplied by your transformation context instead. */ - const createJSDocComment: (comment?: string | undefined, tags?: readonly JSDocTag[] | undefined) => JSDoc; + const createJSDocComment: (comment?: string | NodeArray | undefined, tags?: readonly JSDocTag[] | undefined) => JSDoc; /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ - const createJSDocParameterTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | undefined) => JSDocParameterTag; + const createJSDocParameterTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocParameterTag; /** @deprecated Use `factory.createJSDocClassTag` or the factory supplied by your transformation context instead. */ - const createJSDocClassTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocClassTag; + const createJSDocClassTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocClassTag; /** @deprecated Use `factory.createJSDocAugmentsTag` or the factory supplied by your transformation context instead. */ const createJSDocAugmentsTag: (tagName: Identifier | undefined, className: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression; - }, comment?: string | undefined) => JSDocAugmentsTag; + }, comment?: string | NodeArray | undefined) => JSDocAugmentsTag; /** @deprecated Use `factory.createJSDocEnumTag` or the factory supplied by your transformation context instead. */ - const createJSDocEnumTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | undefined) => JSDocEnumTag; + const createJSDocEnumTag: (tagName: Identifier | undefined, typeExpression: JSDocTypeExpression, comment?: string | NodeArray | undefined) => JSDocEnumTag; /** @deprecated Use `factory.createJSDocTemplateTag` or the factory supplied by your transformation context instead. */ - const createJSDocTemplateTag: (tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | undefined) => JSDocTemplateTag; + const createJSDocTemplateTag: (tagName: Identifier | undefined, constraint: JSDocTypeExpression | undefined, typeParameters: readonly TypeParameterDeclaration[], comment?: string | NodeArray | undefined) => JSDocTemplateTag; /** @deprecated Use `factory.createJSDocTypedefTag` or the factory supplied by your transformation context instead. */ - const createJSDocTypedefTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeLiteral | JSDocTypeExpression | undefined, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | undefined) => JSDocTypedefTag; + const createJSDocTypedefTag: (tagName: Identifier | undefined, typeExpression?: JSDocTypeLiteral | JSDocTypeExpression | undefined, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocTypedefTag; /** @deprecated Use `factory.createJSDocCallbackTag` or the factory supplied by your transformation context instead. */ - const createJSDocCallbackTag: (tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | undefined) => JSDocCallbackTag; + const createJSDocCallbackTag: (tagName: Identifier | undefined, typeExpression: JSDocSignature, fullName?: Identifier | JSDocNamespaceDeclaration | undefined, comment?: string | NodeArray | undefined) => JSDocCallbackTag; /** @deprecated Use `factory.createJSDocSignature` or the factory supplied by your transformation context instead. */ const createJSDocSignature: (typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag | undefined) => JSDocSignature; /** @deprecated Use `factory.createJSDocPropertyTag` or the factory supplied by your transformation context instead. */ - const createJSDocPropertyTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | undefined) => JSDocPropertyTag; + const createJSDocPropertyTag: (tagName: Identifier | undefined, name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, isNameFirst?: boolean | undefined, comment?: string | NodeArray | undefined) => JSDocPropertyTag; /** @deprecated Use `factory.createJSDocTypeLiteral` or the factory supplied by your transformation context instead. */ const createJSDocTypeLiteral: (jsDocPropertyTags?: readonly JSDocPropertyLikeTag[] | undefined, isArrayType?: boolean | undefined) => JSDocTypeLiteral; /** @deprecated Use `factory.createJSDocImplementsTag` or the factory supplied by your transformation context instead. */ const createJSDocImplementsTag: (tagName: Identifier | undefined, className: ExpressionWithTypeArguments & { readonly expression: Identifier | PropertyAccessEntityNameExpression; - }, comment?: string | undefined) => JSDocImplementsTag; + }, comment?: string | NodeArray | undefined) => JSDocImplementsTag; /** @deprecated Use `factory.createJSDocAuthorTag` or the factory supplied by your transformation context instead. */ - const createJSDocAuthorTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocAuthorTag; + const createJSDocAuthorTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocAuthorTag; /** @deprecated Use `factory.createJSDocPublicTag` or the factory supplied by your transformation context instead. */ - const createJSDocPublicTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocPublicTag; + const createJSDocPublicTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPublicTag; /** @deprecated Use `factory.createJSDocPrivateTag` or the factory supplied by your transformation context instead. */ - const createJSDocPrivateTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocPrivateTag; + const createJSDocPrivateTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocPrivateTag; /** @deprecated Use `factory.createJSDocProtectedTag` or the factory supplied by your transformation context instead. */ - const createJSDocProtectedTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocProtectedTag; + const createJSDocProtectedTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocProtectedTag; /** @deprecated Use `factory.createJSDocReadonlyTag` or the factory supplied by your transformation context instead. */ - const createJSDocReadonlyTag: (tagName: Identifier | undefined, comment?: string | undefined) => JSDocReadonlyTag; + const createJSDocReadonlyTag: (tagName: Identifier | undefined, comment?: string | NodeArray | undefined) => JSDocReadonlyTag; /** @deprecated Use `factory.createJSDocUnknownTag` or the factory supplied by your transformation context instead. */ - const createJSDocTag: (tagName: Identifier, comment?: string | undefined) => JSDocUnknownTag; + const createJSDocTag: (tagName: Identifier, comment?: string | NodeArray | undefined) => JSDocUnknownTag; /** @deprecated Use `factory.createJsxElement` or the factory supplied by your transformation context instead. */ const createJsxElement: (openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement) => JsxElement; /** @deprecated Use `factory.updateJsxElement` or the factory supplied by your transformation context instead. */ @@ -7217,6 +7372,10 @@ declare namespace ts { */ interface Map extends ESMap { } + /** + * @deprecated Use `isMemberName` instead. + */ + const isIdentifierOrPrivateIdentifier: (node: Node) => node is MemberName; } export = ts; \ No newline at end of file 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 84f8b518d49a..615ad27f3f7d 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 @@ -286,11 +286,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.2"; + ts.versionMajorMinor = "4.3"; // 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.2.3"; + ts.version = "4.3.2"; /* @internal */ var Comparison; (function (Comparison) { @@ -2594,6 +2594,8 @@ var ts; } } Debug.assertMissingNode = assertMissingNode; + function type(_value) { } + Debug.type = type; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -2855,11 +2857,11 @@ var ts; this.objectFlags & 8 /* Tuple */ ? "TupleType" : this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 2048 /* ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~2367 /* ObjectTypeKindMask */ : 0; + var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); } }, @@ -3662,22 +3664,14 @@ var ts; var ts; (function (ts) { // enable the above using startTracing() -})(ts || (ts = {})); -// `tracingEnabled` should never be used directly, only through the above -/* @internal */ -(function (ts) { + // `tracingEnabled` should never be used directly, only through the above var tracingEnabled; (function (tracingEnabled) { - var Mode; - (function (Mode) { - Mode[Mode["Project"] = 0] = "Project"; - Mode[Mode["Build"] = 1] = "Build"; - Mode[Mode["Server"] = 2] = "Server"; - })(Mode = tracingEnabled.Mode || (tracingEnabled.Mode = {})); var fs; var traceCount = 0; var traceFd = 0; var mode; + var typeCatalog = []; // NB: id is index + 1 var legendPath; var legend = []; ; @@ -3693,6 +3687,7 @@ var ts; } } mode = tracingMode; + typeCatalog.length = 0; if (legendPath === undefined) { legendPath = ts.combinePaths(traceDir, "legend.json"); } @@ -3700,8 +3695,8 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === 1 /* Build */ ? "." + process.pid + "-" + ++traceCount - : mode === 2 /* Server */ ? "." + process.pid + var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount + : mode === "server" ? "." + process.pid : ""; var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); @@ -3720,13 +3715,13 @@ var ts; } tracingEnabled.startTracing = startTracing; /** Stops tracing for the in-progress project and dumps the type catalog. */ - function stopTracing(typeCatalog) { + function stopTracing() { ts.Debug.assert(ts.tracing, "Tracing is not in progress"); - ts.Debug.assert(!!typeCatalog === (mode !== 2 /* Server */)); // Have a type catalog iff not in server mode + ts.Debug.assert(!!typeCatalog.length === (mode !== "server")); // Have a type catalog iff not in server mode fs.writeSync(traceFd, "\n]\n"); fs.closeSync(traceFd); ts.tracing = undefined; - if (typeCatalog) { + if (typeCatalog.length) { dumpTypes(typeCatalog); } else { @@ -3736,6 +3731,12 @@ var ts; } } tracingEnabled.stopTracing = stopTracing; + function recordType(type) { + if (mode !== "server") { + typeCatalog.push(type); + } + } + tracingEnabled.recordType = recordType; var Phase; (function (Phase) { Phase["Parse"] = "parse"; @@ -3794,7 +3795,7 @@ var ts; function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === 2 /* Server */ && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* CheckTypes */) return; ts.performance.mark("beginTracing"); fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); @@ -3806,14 +3807,24 @@ var ts; ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); } - function indexFromOne(lc) { - return { - line: lc.line + 1, - character: lc.character + 1, - }; + function getLocation(node) { + var file = ts.getSourceFileOfNode(node); + return !file + ? undefined + : { + path: file.path, + start: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.pos)), + end: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.end)), + }; + function indexFromOne(lc) { + return { + line: lc.line + 1, + character: lc.character + 1, + }; + } } function dumpTypes(types) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; ts.performance.mark("beginDumpTypes"); var typesPath = legend[legend.length - 1].typesPath; var typesFd = fs.openSync(typesPath, "w"); @@ -3825,15 +3836,13 @@ var ts; var type = types[i]; var objectFlags = type.objectFlags; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; - var firstDeclaration = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b[0]; - var firstFile = firstDeclaration && ts.getSourceFileOfNode(firstDeclaration); // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { try { - display = (_c = type.checker) === null || _c === void 0 ? void 0 : _c.typeToString(type); + display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } - catch (_s) { + catch (_y) { display = undefined; } } @@ -3841,26 +3850,52 @@ var ts; if (type.flags & 8388608 /* IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { - indexedAccessObjectType: (_d = indexedAccessType.objectType) === null || _d === void 0 ? void 0 : _d.id, - indexedAccessIndexType: (_e = indexedAccessType.indexType) === null || _e === void 0 ? void 0 : _e.id, + indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, + indexedAccessIndexType: (_d = indexedAccessType.indexType) === null || _d === void 0 ? void 0 : _d.id, }; } var referenceProperties = {}; if (objectFlags & 4 /* Reference */) { var referenceType = type; referenceProperties = { - instantiatedType: (_f = referenceType.target) === null || _f === void 0 ? void 0 : _f.id, - typeArguments: (_g = referenceType.resolvedTypeArguments) === null || _g === void 0 ? void 0 : _g.map(function (t) { return t.id; }), + instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, + typeArguments: (_f = referenceType.resolvedTypeArguments) === null || _f === void 0 ? void 0 : _f.map(function (t) { return t.id; }), + referenceLocation: getLocation(referenceType.node), }; } var conditionalProperties = {}; if (type.flags & 16777216 /* Conditional */) { var conditionalType = type; conditionalProperties = { - conditionalCheckType: (_h = conditionalType.checkType) === null || _h === void 0 ? void 0 : _h.id, - conditionalExtendsType: (_j = conditionalType.extendsType) === null || _j === void 0 ? void 0 : _j.id, - conditionalTrueType: (_l = (_k = conditionalType.resolvedTrueType) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : -1, - conditionalFalseType: (_o = (_m = conditionalType.resolvedFalseType) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : -1, + conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, + conditionalExtendsType: (_h = conditionalType.extendsType) === null || _h === void 0 ? void 0 : _h.id, + conditionalTrueType: (_k = (_j = conditionalType.resolvedTrueType) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : -1, + conditionalFalseType: (_m = (_l = conditionalType.resolvedFalseType) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : -1, + }; + } + var substitutionProperties = {}; + if (type.flags & 33554432 /* Substitution */) { + var substitutionType = type; + substitutionProperties = { + substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, + substituteType: (_p = substitutionType.substitute) === null || _p === void 0 ? void 0 : _p.id, + }; + } + var reverseMappedProperties = {}; + if (objectFlags & 1024 /* ReverseMapped */) { + var reverseMappedType = type; + reverseMappedProperties = { + reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, + reverseMappedMappedType: (_r = reverseMappedType.mappedType) === null || _r === void 0 ? void 0 : _r.id, + reverseMappedConstraintType: (_s = reverseMappedType.constraintType) === null || _s === void 0 ? void 0 : _s.id, + }; + } + var evolvingArrayProperties = {}; + if (objectFlags & 256 /* EvolvingArray */) { + var evolvingArrayType = type; + evolvingArrayProperties = { + evolvingArrayElementType: evolvingArrayType.elementType.id, + evolvingArrayFinalType: (_t = evolvingArrayType.finalArrayType) === null || _t === void 0 ? void 0 : _t.id, }; } // We can't print out an arbitrary object, so just assign each one a unique number. @@ -3874,11 +3909,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, unionTypes: (type.flags & 1048576 /* Union */) ? (_p = type.types) === null || _p === void 0 ? void 0 : _p.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_q = type.aliasTypeArguments) === null || _q === void 0 ? void 0 : _q.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_r = type.type) === null || _r === void 0 ? void 0 : _r.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), { firstDeclaration: firstDeclaration && { - path: firstFile.path, - start: indexFromOne(ts.getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)), - end: indexFromOne(ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(firstDeclaration), firstDeclaration.end)), - }, flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -3896,12 +3927,10 @@ var ts; fs.writeFileSync(legendPath, JSON.stringify(legend)); } tracingEnabled.dumpLegend = dumpLegend; - })(tracingEnabled = ts.tracingEnabled || (ts.tracingEnabled = {})); -})(ts || (ts = {})); -/*@internal*/ -(function (ts) { + })(tracingEnabled || (tracingEnabled = {})); // define after tracingEnabled is initialized - ts.startTracing = ts.tracingEnabled.startTracing; + ts.startTracing = tracingEnabled.startTracing; + ts.dumpTracingLegend = tracingEnabled.dumpLegend; })(ts || (ts = {})); var ts; (function (ts) { @@ -4077,215 +4106,216 @@ var ts; SyntaxKind[SyntaxKind["FromKeyword"] = 153] = "FromKeyword"; SyntaxKind[SyntaxKind["GlobalKeyword"] = 154] = "GlobalKeyword"; SyntaxKind[SyntaxKind["BigIntKeyword"] = 155] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 156] = "OfKeyword"; + SyntaxKind[SyntaxKind["OverrideKeyword"] = 156] = "OverrideKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 157] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 157] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 158] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 158] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 159] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 159] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 160] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 161] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 160] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 161] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 162] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 162] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 163] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 164] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 165] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 166] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 167] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 168] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 169] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 170] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 171] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 163] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 164] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 165] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 166] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 167] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 168] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 169] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 170] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 171] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 172] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 172] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 173] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 174] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 175] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 176] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 177] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 178] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 179] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 180] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 181] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 182] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 183] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 184] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 185] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 186] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 187] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 188] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 189] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 190] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 191] = "LiteralType"; - SyntaxKind[SyntaxKind["NamedTupleMember"] = 192] = "NamedTupleMember"; - SyntaxKind[SyntaxKind["TemplateLiteralType"] = 193] = "TemplateLiteralType"; - SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 194] = "TemplateLiteralTypeSpan"; - SyntaxKind[SyntaxKind["ImportType"] = 195] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 173] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 174] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 175] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 176] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 177] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 178] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 179] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 180] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 181] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 182] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 183] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 184] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 185] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 186] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 187] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 188] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 189] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 190] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 191] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 192] = "LiteralType"; + SyntaxKind[SyntaxKind["NamedTupleMember"] = 193] = "NamedTupleMember"; + SyntaxKind[SyntaxKind["TemplateLiteralType"] = 194] = "TemplateLiteralType"; + SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 195] = "TemplateLiteralTypeSpan"; + SyntaxKind[SyntaxKind["ImportType"] = 196] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 196] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 197] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 198] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 197] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 198] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 199] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 199] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 200] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 201] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 202] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 203] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 204] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 205] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 206] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 207] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 208] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 209] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 210] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 211] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 212] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 213] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 214] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 215] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 216] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 217] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 218] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 219] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 220] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 221] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 222] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 223] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 224] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 225] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 226] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 227] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 200] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 201] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 202] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 203] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 204] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 205] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 206] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 207] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 208] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 209] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 210] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 211] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 212] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 213] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 214] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 215] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 216] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 217] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 218] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 219] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 220] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 221] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 222] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 223] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 224] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 225] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 226] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 227] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 228] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 228] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 229] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 229] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 230] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 230] = "Block"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 231] = "EmptyStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 232] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 233] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 234] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 235] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 236] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 237] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 238] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 239] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 240] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 241] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 242] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 243] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 244] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 245] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 246] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 247] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 248] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 249] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 250] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 251] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 252] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 253] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 254] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 255] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 256] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 257] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 258] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 259] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 260] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 261] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 262] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 263] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 264] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 265] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 266] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 267] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 268] = "NamedExports"; - SyntaxKind[SyntaxKind["NamespaceExport"] = 269] = "NamespaceExport"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 270] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 271] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 231] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 232] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 233] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 234] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 235] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 236] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 237] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 238] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 239] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 240] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 241] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 242] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 243] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 244] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 245] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 246] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 247] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 248] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 249] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 250] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 251] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 252] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 253] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 254] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 255] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 256] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 257] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 258] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 259] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 260] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 261] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 262] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 263] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 264] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 265] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 266] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 267] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 268] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 269] = "NamedExports"; + SyntaxKind[SyntaxKind["NamespaceExport"] = 270] = "NamespaceExport"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 271] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 272] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 272] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 273] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 273] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 274] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 275] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 276] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 277] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 278] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 279] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 280] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 281] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 282] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 283] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 274] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 275] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 276] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 277] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 278] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 279] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 280] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 281] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 282] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 283] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 284] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 284] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 285] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 286] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 287] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 285] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 286] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 287] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 288] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 288] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 289] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 290] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 289] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 290] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 291] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 291] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 292] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 292] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 293] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 294] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 295] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 296] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 293] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 294] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 295] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 296] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 297] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 297] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 298] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 299] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 300] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 298] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 299] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 300] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 301] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 301] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocNameReference"] = 302] = "JSDocNameReference"; - // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 303] = "JSDocAllType"; - // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 304] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 305] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 306] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 307] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 308] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 309] = "JSDocVariadicType"; - // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 310] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 311] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 312] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 313] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 314] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 315] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 316] = "JSDocImplementsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 317] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 318] = "JSDocDeprecatedTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 319] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocPublicTag"] = 320] = "JSDocPublicTag"; - SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 321] = "JSDocPrivateTag"; - SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 322] = "JSDocProtectedTag"; - SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 323] = "JSDocReadonlyTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 324] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 325] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 326] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 327] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 328] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 329] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 330] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 331] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocSeeTag"] = 332] = "JSDocSeeTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 333] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 302] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocNameReference"] = 303] = "JSDocNameReference"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 304] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 305] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 306] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 307] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 308] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 309] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 310] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 311] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 312] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocText"] = 313] = "JSDocText"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 314] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 315] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocLink"] = 316] = "JSDocLink"; + SyntaxKind[SyntaxKind["JSDocTag"] = 317] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 318] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 319] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 320] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 321] = "JSDocDeprecatedTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 322] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 323] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 324] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 325] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 326] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 327] = "JSDocOverrideTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 328] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 329] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 330] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 331] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 332] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 333] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 334] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 335] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocSeeTag"] = 336] = "JSDocSeeTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 337] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 334] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 338] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 335] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 336] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 337] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 338] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 339] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 340] = "SyntheticReferenceExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 339] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 340] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 341] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 342] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 343] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 344] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 341] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 345] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 77] = "LastAssignment"; @@ -4294,15 +4324,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 80] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 115] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 80] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 156] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 157] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 116] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 124] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 172] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 195] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 173] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 196] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 77] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 156] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 157] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -4311,15 +4341,15 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 77] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstStatement"] = 232] = "FirstStatement"; - SyntaxKind[SyntaxKind["LastStatement"] = 248] = "LastStatement"; - SyntaxKind[SyntaxKind["FirstNode"] = 157] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 301] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 333] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 314] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 333] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstStatement"] = 233] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 249] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 158] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 302] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 337] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 317] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 337] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 125] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 156] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 157] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -4389,14 +4419,15 @@ var ts; ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; ModifierFlags[ModifierFlags["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; ModifierFlags[ModifierFlags["Deprecated"] = 8192] = "Deprecated"; + ModifierFlags[ModifierFlags["Override"] = 16384] = "Override"; ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. - ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 92] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; - ModifierFlags[ModifierFlags["TypeScriptModifier"] = 2270] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 18654] = "TypeScriptModifier"; ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; - ModifierFlags[ModifierFlags["All"] = 11263] = "All"; + ModifierFlags[ModifierFlags["All"] = 27647] = "All"; })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); var JsxFlags; (function (JsxFlags) { @@ -4577,6 +4608,8 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["NoUndefinedOptionalParameterType"] = 1073741824] = "NoUndefinedOptionalParameterType"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ NodeBuilderFlags[NodeBuilderFlags["AllowQualifedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifedNameInPlaceOfIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowAnonymousIdentifier"] = 131072] = "AllowAnonymousIdentifier"; NodeBuilderFlags[NodeBuilderFlags["AllowEmptyUnionOrIntersection"] = 262144] = "AllowEmptyUnionOrIntersection"; @@ -4591,7 +4624,6 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["InObjectTypeLiteral"] = 4194304] = "InObjectTypeLiteral"; NodeBuilderFlags[NodeBuilderFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; NodeBuilderFlags[NodeBuilderFlags["InInitialEntityName"] = 16777216] = "InInitialEntityName"; - NodeBuilderFlags[NodeBuilderFlags["InReverseMappedType"] = 33554432] = "InReverseMappedType"; })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); // Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment var TypeFormatFlags; @@ -4944,6 +4976,9 @@ var ts; /* @internal */ TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject"; })(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 + // for a certain TypeFlags value to determine their meaning. var ObjectFlags; (function (ObjectFlags) { ObjectFlags[ObjectFlags["Class"] = 1] = "Class"; @@ -4956,50 +4991,59 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; - ObjectFlags[ObjectFlags["ContainsSpread"] = 1024] = "ContainsSpread"; - ObjectFlags[ObjectFlags["ReverseMapped"] = 2048] = "ReverseMapped"; - ObjectFlags[ObjectFlags["JsxAttributes"] = 4096] = "JsxAttributes"; - ObjectFlags[ObjectFlags["MarkerType"] = 8192] = "MarkerType"; - ObjectFlags[ObjectFlags["JSLiteral"] = 16384] = "JSLiteral"; - ObjectFlags[ObjectFlags["FreshLiteral"] = 32768] = "FreshLiteral"; - ObjectFlags[ObjectFlags["ArrayLiteral"] = 65536] = "ArrayLiteral"; - ObjectFlags[ObjectFlags["ObjectRestType"] = 131072] = "ObjectRestType"; + ObjectFlags[ObjectFlags["ReverseMapped"] = 1024] = "ReverseMapped"; + ObjectFlags[ObjectFlags["JsxAttributes"] = 2048] = "JsxAttributes"; + ObjectFlags[ObjectFlags["MarkerType"] = 4096] = "MarkerType"; + ObjectFlags[ObjectFlags["JSLiteral"] = 8192] = "JSLiteral"; + ObjectFlags[ObjectFlags["FreshLiteral"] = 16384] = "FreshLiteral"; + ObjectFlags[ObjectFlags["ArrayLiteral"] = 32768] = "ArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["PrimitiveUnion"] = 262144] = "PrimitiveUnion"; + ObjectFlags[ObjectFlags["PrimitiveUnion"] = 65536] = "PrimitiveUnion"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsWideningType"] = 524288] = "ContainsWideningType"; + ObjectFlags[ObjectFlags["ContainsWideningType"] = 131072] = "ContainsWideningType"; /* @internal */ - ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 1048576] = "ContainsObjectOrArrayLiteral"; + ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 262144] = "ContainsObjectOrArrayLiteral"; /* @internal */ - ObjectFlags[ObjectFlags["NonInferrableType"] = 2097152] = "NonInferrableType"; + ObjectFlags[ObjectFlags["NonInferrableType"] = 524288] = "NonInferrableType"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; + ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 1048576] = "CouldContainTypeVariablesComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; + ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 2097152] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; + ObjectFlags[ObjectFlags["RequiresWidening"] = 393216] = "RequiresWidening"; /* @internal */ - ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + ObjectFlags[ObjectFlags["PropagatingFlags"] = 917504] = "PropagatingFlags"; + // Object flags that uniquely identify the kind of ObjectType /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 67108864] = "CouldContainTypeVariablesComputed"; + ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 1343] = "ObjectTypeKindMask"; + // Flags that require TypeFlags.Object + ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread"; + ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType"; /* @internal */ - ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 134217728] = "CouldContainTypeVariables"; + ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone"; + // Flags that require TypeFlags.Object and ObjectFlags.Reference /* @internal */ - ObjectFlags[ObjectFlags["ContainsIntersections"] = 268435456] = "ContainsIntersections"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated"; /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 268435456] = "IsNeverIntersectionComputed"; + ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists"; + // Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution /* @internal */ - ObjectFlags[ObjectFlags["IsNeverIntersection"] = 536870912] = "IsNeverIntersection"; + ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 1073741824] = "IsClassInstanceClone"; - ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; + ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; + /* @internal */ + ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; /* @internal */ - ObjectFlags[ObjectFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; + ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + // Flags that require TypeFlags.Union /* @internal */ - ObjectFlags[ObjectFlags["PropagatingFlags"] = 3670016] = "PropagatingFlags"; - // Object flags that uniquely identify the kind of ObjectType + ObjectFlags[ObjectFlags["ContainsIntersections"] = 67108864] = "ContainsIntersections"; + // Flags that require TypeFlags.Intersection /* @internal */ - ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 2367] = "ObjectTypeKindMask"; + ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 67108864] = "IsNeverIntersectionComputed"; + /* @internal */ + ObjectFlags[ObjectFlags["IsNeverIntersection"] = 134217728] = "IsNeverIntersection"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); /* @internal */ var VarianceFlags; @@ -5073,16 +5117,17 @@ var ts; (function (InferencePriority) { InferencePriority[InferencePriority["NakedTypeVariable"] = 1] = "NakedTypeVariable"; InferencePriority[InferencePriority["SpeculativeTuple"] = 2] = "SpeculativeTuple"; - InferencePriority[InferencePriority["HomomorphicMappedType"] = 4] = "HomomorphicMappedType"; - InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 8] = "PartialHomomorphicMappedType"; - InferencePriority[InferencePriority["MappedTypeConstraint"] = 16] = "MappedTypeConstraint"; - InferencePriority[InferencePriority["ContravariantConditional"] = 32] = "ContravariantConditional"; - InferencePriority[InferencePriority["ReturnType"] = 64] = "ReturnType"; - InferencePriority[InferencePriority["LiteralKeyof"] = 128] = "LiteralKeyof"; - InferencePriority[InferencePriority["NoConstraints"] = 256] = "NoConstraints"; - InferencePriority[InferencePriority["AlwaysStrict"] = 512] = "AlwaysStrict"; - InferencePriority[InferencePriority["MaxValue"] = 1024] = "MaxValue"; - InferencePriority[InferencePriority["PriorityImpliesCombination"] = 208] = "PriorityImpliesCombination"; + InferencePriority[InferencePriority["SubstituteSource"] = 4] = "SubstituteSource"; + InferencePriority[InferencePriority["HomomorphicMappedType"] = 8] = "HomomorphicMappedType"; + InferencePriority[InferencePriority["PartialHomomorphicMappedType"] = 16] = "PartialHomomorphicMappedType"; + InferencePriority[InferencePriority["MappedTypeConstraint"] = 32] = "MappedTypeConstraint"; + InferencePriority[InferencePriority["ContravariantConditional"] = 64] = "ContravariantConditional"; + InferencePriority[InferencePriority["ReturnType"] = 128] = "ReturnType"; + InferencePriority[InferencePriority["LiteralKeyof"] = 256] = "LiteralKeyof"; + InferencePriority[InferencePriority["NoConstraints"] = 512] = "NoConstraints"; + InferencePriority[InferencePriority["AlwaysStrict"] = 1024] = "AlwaysStrict"; + InferencePriority[InferencePriority["MaxValue"] = 2048] = "MaxValue"; + InferencePriority[InferencePriority["PriorityImpliesCombination"] = 416] = "PriorityImpliesCombination"; InferencePriority[InferencePriority["Circularity"] = -1] = "Circularity"; })(InferencePriority = ts.InferencePriority || (ts.InferencePriority = {})); /* @internal */ @@ -5160,20 +5205,23 @@ var ts; WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval"; WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval"; WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; - WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents"; - WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory"; + WatchFileKind[WatchFileKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; + WatchFileKind[WatchFileKind["UseFsEvents"] = 4] = "UseFsEvents"; + WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 5] = "UseFsEventsOnParentDirectory"; })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {})); var WatchDirectoryKind; (function (WatchDirectoryKind) { WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents"; WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval"; WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling"; + WatchDirectoryKind[WatchDirectoryKind["FixedChunkSizePolling"] = 3] = "FixedChunkSizePolling"; })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {})); var PollingWatchKind; (function (PollingWatchKind) { PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval"; PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval"; PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority"; + PollingWatchKind[PollingWatchKind["FixedChunkSize"] = 3] = "FixedChunkSize"; })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {})); var ModuleKind; (function (ModuleKind) { @@ -5234,6 +5282,7 @@ var ts; ScriptTarget[ScriptTarget["ES2018"] = 5] = "ES2018"; ScriptTarget[ScriptTarget["ES2019"] = 6] = "ES2019"; ScriptTarget[ScriptTarget["ES2020"] = 7] = "ES2020"; + ScriptTarget[ScriptTarget["ES2021"] = 8] = "ES2021"; ScriptTarget[ScriptTarget["ESNext"] = 99] = "ESNext"; ScriptTarget[ScriptTarget["JSON"] = 100] = "JSON"; ScriptTarget[ScriptTarget["Latest"] = 99] = "Latest"; @@ -5396,29 +5445,30 @@ var ts; TransformFlags[TransformFlags["ContainsTypeScript"] = 1] = "ContainsTypeScript"; TransformFlags[TransformFlags["ContainsJsx"] = 2] = "ContainsJsx"; TransformFlags[TransformFlags["ContainsESNext"] = 4] = "ContainsESNext"; - TransformFlags[TransformFlags["ContainsES2020"] = 8] = "ContainsES2020"; - TransformFlags[TransformFlags["ContainsES2019"] = 16] = "ContainsES2019"; - TransformFlags[TransformFlags["ContainsES2018"] = 32] = "ContainsES2018"; - TransformFlags[TransformFlags["ContainsES2017"] = 64] = "ContainsES2017"; - TransformFlags[TransformFlags["ContainsES2016"] = 128] = "ContainsES2016"; - TransformFlags[TransformFlags["ContainsES2015"] = 256] = "ContainsES2015"; - TransformFlags[TransformFlags["ContainsGenerator"] = 512] = "ContainsGenerator"; - TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 1024] = "ContainsDestructuringAssignment"; + TransformFlags[TransformFlags["ContainsES2021"] = 8] = "ContainsES2021"; + TransformFlags[TransformFlags["ContainsES2020"] = 16] = "ContainsES2020"; + TransformFlags[TransformFlags["ContainsES2019"] = 32] = "ContainsES2019"; + TransformFlags[TransformFlags["ContainsES2018"] = 64] = "ContainsES2018"; + TransformFlags[TransformFlags["ContainsES2017"] = 128] = "ContainsES2017"; + TransformFlags[TransformFlags["ContainsES2016"] = 256] = "ContainsES2016"; + TransformFlags[TransformFlags["ContainsES2015"] = 512] = "ContainsES2015"; + TransformFlags[TransformFlags["ContainsGenerator"] = 1024] = "ContainsGenerator"; + TransformFlags[TransformFlags["ContainsDestructuringAssignment"] = 2048] = "ContainsDestructuringAssignment"; // Markers // - Flags used to indicate that a subtree contains a specific transformation. - TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 2048] = "ContainsTypeScriptClassSyntax"; - TransformFlags[TransformFlags["ContainsLexicalThis"] = 4096] = "ContainsLexicalThis"; - TransformFlags[TransformFlags["ContainsRestOrSpread"] = 8192] = "ContainsRestOrSpread"; - TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 16384] = "ContainsObjectRestOrSpread"; - TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 32768] = "ContainsComputedPropertyName"; - TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 65536] = "ContainsBlockScopedBinding"; - TransformFlags[TransformFlags["ContainsBindingPattern"] = 131072] = "ContainsBindingPattern"; - TransformFlags[TransformFlags["ContainsYield"] = 262144] = "ContainsYield"; - TransformFlags[TransformFlags["ContainsAwait"] = 524288] = "ContainsAwait"; - TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 1048576] = "ContainsHoistedDeclarationOrCompletion"; - TransformFlags[TransformFlags["ContainsDynamicImport"] = 2097152] = "ContainsDynamicImport"; - TransformFlags[TransformFlags["ContainsClassFields"] = 4194304] = "ContainsClassFields"; - TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 8388608] = "ContainsPossibleTopLevelAwait"; + TransformFlags[TransformFlags["ContainsTypeScriptClassSyntax"] = 4096] = "ContainsTypeScriptClassSyntax"; + TransformFlags[TransformFlags["ContainsLexicalThis"] = 8192] = "ContainsLexicalThis"; + TransformFlags[TransformFlags["ContainsRestOrSpread"] = 16384] = "ContainsRestOrSpread"; + TransformFlags[TransformFlags["ContainsObjectRestOrSpread"] = 32768] = "ContainsObjectRestOrSpread"; + TransformFlags[TransformFlags["ContainsComputedPropertyName"] = 65536] = "ContainsComputedPropertyName"; + TransformFlags[TransformFlags["ContainsBlockScopedBinding"] = 131072] = "ContainsBlockScopedBinding"; + TransformFlags[TransformFlags["ContainsBindingPattern"] = 262144] = "ContainsBindingPattern"; + TransformFlags[TransformFlags["ContainsYield"] = 524288] = "ContainsYield"; + TransformFlags[TransformFlags["ContainsAwait"] = 1048576] = "ContainsAwait"; + TransformFlags[TransformFlags["ContainsHoistedDeclarationOrCompletion"] = 2097152] = "ContainsHoistedDeclarationOrCompletion"; + TransformFlags[TransformFlags["ContainsDynamicImport"] = 4194304] = "ContainsDynamicImport"; + TransformFlags[TransformFlags["ContainsClassFields"] = 8388608] = "ContainsClassFields"; + TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 16777216] = "ContainsPossibleTopLevelAwait"; // Please leave this as 1 << 29. // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. // It is a good reminder of how much room we have left @@ -5428,37 +5478,38 @@ var ts; TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; TransformFlags[TransformFlags["AssertJsx"] = 2] = "AssertJsx"; TransformFlags[TransformFlags["AssertESNext"] = 4] = "AssertESNext"; - TransformFlags[TransformFlags["AssertES2020"] = 8] = "AssertES2020"; - TransformFlags[TransformFlags["AssertES2019"] = 16] = "AssertES2019"; - TransformFlags[TransformFlags["AssertES2018"] = 32] = "AssertES2018"; - TransformFlags[TransformFlags["AssertES2017"] = 64] = "AssertES2017"; - TransformFlags[TransformFlags["AssertES2016"] = 128] = "AssertES2016"; - TransformFlags[TransformFlags["AssertES2015"] = 256] = "AssertES2015"; - TransformFlags[TransformFlags["AssertGenerator"] = 512] = "AssertGenerator"; - TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 1024] = "AssertDestructuringAssignment"; + TransformFlags[TransformFlags["AssertES2021"] = 8] = "AssertES2021"; + TransformFlags[TransformFlags["AssertES2020"] = 16] = "AssertES2020"; + TransformFlags[TransformFlags["AssertES2019"] = 32] = "AssertES2019"; + TransformFlags[TransformFlags["AssertES2018"] = 64] = "AssertES2018"; + TransformFlags[TransformFlags["AssertES2017"] = 128] = "AssertES2017"; + TransformFlags[TransformFlags["AssertES2016"] = 256] = "AssertES2016"; + TransformFlags[TransformFlags["AssertES2015"] = 512] = "AssertES2015"; + TransformFlags[TransformFlags["AssertGenerator"] = 1024] = "AssertGenerator"; + TransformFlags[TransformFlags["AssertDestructuringAssignment"] = 2048] = "AssertDestructuringAssignment"; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes"; TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes"; TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 547309568] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 547313664] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 547311616] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 538923008] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 536875008] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 536905728] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 546379776] = "ModuleExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 557748224] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = 557756416] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = 557752320] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 540975104] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = 536879104] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = 536940544] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = 555888640] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536922112] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536879104] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537018368] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 536973312] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536887296] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537165824] = "VariableDeclarationListExcludes"; TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536887296] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536879104] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = 536903680] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = 536887296] = "BindingPatternExcludes"; // Propagating flags // - Bitmasks for flags that should propagate from a child - TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 4096] = "PropertyNamePropagatingFlags"; + TransformFlags[TransformFlags["PropertyNamePropagatingFlags"] = 8192] = "PropertyNamePropagatingFlags"; // Masks // - Additional bitmasks })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); @@ -6446,6 +6497,11 @@ var ts; })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {})); /* @internal */ ts.missingFileModifiedTime = new Date(0); // Any subsequent modification will occur after this time + /* @internal */ + function getModifiedTime(host, fileName) { + return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; + } + ts.getModifiedTime = getModifiedTime; function createPollingIntervalBasedLevels(levels) { var _a; return _a = {}, @@ -6502,6 +6558,51 @@ var ts; } } ts.setCustomPollingValues = setCustomPollingValues; + function pollWatchedFileQueue(host, queue, pollIndex, chunkSize, callbackOnWatchFileStat) { + var definedValueCopyToIndex = pollIndex; + // Max visit would be all elements of the queue + for (var canVisit = queue.length; chunkSize && canVisit; nextPollIndex(), canVisit--) { + var watchedFile = queue[pollIndex]; + if (!watchedFile) { + continue; + } + else if (watchedFile.isClosed) { + queue[pollIndex] = undefined; + continue; + } + // Only files polled count towards chunkSize + chunkSize--; + var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(host, watchedFile.fileName)); + if (watchedFile.isClosed) { + // Closed watcher as part of callback + queue[pollIndex] = undefined; + continue; + } + callbackOnWatchFileStat === null || callbackOnWatchFileStat === void 0 ? void 0 : callbackOnWatchFileStat(watchedFile, pollIndex, fileChanged); + // Defragment the queue while we are at it + if (queue[pollIndex]) { + // Copy this file to the non hole location + if (definedValueCopyToIndex < pollIndex) { + queue[definedValueCopyToIndex] = watchedFile; + queue[pollIndex] = undefined; + } + definedValueCopyToIndex++; + } + } + // Return next poll index + return pollIndex; + function nextPollIndex() { + pollIndex++; + if (pollIndex === queue.length) { + if (definedValueCopyToIndex < pollIndex) { + // There are holes from definedValueCopyToIndex to end of queue, change queue size + queue.length = definedValueCopyToIndex; + } + pollIndex = 0; + definedValueCopyToIndex = 0; + } + } + } /* @internal */ function createDynamicPriorityPollingWatchFile(host) { var watchedFiles = []; @@ -6515,7 +6616,7 @@ var ts; fileName: fileName, callback: callback, unchangedPolls: 0, - mtime: getModifiedTime(fileName) + mtime: getModifiedTime(host, fileName) }; watchedFiles.push(file); addToPollingIntervalQueue(file, defaultPollingInterval); @@ -6558,25 +6659,9 @@ var ts; } } function pollQueue(queue, pollingInterval, pollIndex, chunkSize) { - // Max visit would be all elements of the queue - var needsVisit = queue.length; - var definedValueCopyToIndex = pollIndex; - for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) { - var watchedFile = queue[pollIndex]; - if (!watchedFile) { - continue; - } - else if (watchedFile.isClosed) { - queue[pollIndex] = undefined; - continue; - } - polled++; - var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName)); - if (watchedFile.isClosed) { - // Closed watcher as part of callback - queue[pollIndex] = undefined; - } - else if (fileChanged) { + return pollWatchedFileQueue(host, queue, pollIndex, chunkSize, onWatchFileStat); + function onWatchFileStat(watchedFile, pollIndex, fileChanged) { + if (fileChanged) { watchedFile.unchangedPolls = 0; // Changed files go to changedFilesInLastPoll queue if (queue !== changedFilesInLastPoll) { @@ -6598,27 +6683,6 @@ var ts; queue[pollIndex] = undefined; addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High); } - if (queue[pollIndex]) { - // Copy this file to the non hole location - if (definedValueCopyToIndex < pollIndex) { - queue[definedValueCopyToIndex] = watchedFile; - queue[pollIndex] = undefined; - } - definedValueCopyToIndex++; - } - } - // Return next poll index - return pollIndex; - function nextPollIndex() { - pollIndex++; - if (pollIndex === queue.length) { - if (definedValueCopyToIndex < pollIndex) { - // There are holes from nextDefinedValueIndex to end of queue, change queue size - queue.length = definedValueCopyToIndex; - } - pollIndex = 0; - definedValueCopyToIndex = 0; - } } } function pollingIntervalQueue(pollingInterval) { @@ -6647,9 +6711,6 @@ var ts; function scheduleNextPoll(pollingInterval) { pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval)); } - function getModifiedTime(fileName) { - return host.getModifiedTime(fileName) || ts.missingFileModifiedTime; - } } ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile; function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) { @@ -6700,6 +6761,37 @@ var ts; return watcher; } } + function createFixedChunkSizePollingWatchFile(host) { + var watchedFiles = []; + var pollIndex = 0; + var pollScheduled; + return watchFile; + function watchFile(fileName, callback) { + var file = { + fileName: fileName, + callback: callback, + mtime: getModifiedTime(host, fileName) + }; + watchedFiles.push(file); + scheduleNextPoll(); + return { + close: function () { + file.isClosed = true; + ts.unorderedRemoveItem(watchedFiles, file); + } + }; + } + function pollQueue() { + pollScheduled = undefined; + pollIndex = pollWatchedFileQueue(host, watchedFiles, pollIndex, pollingChunkSize[PollingInterval.Low]); + scheduleNextPoll(); + } + function scheduleNextPoll() { + if (!watchedFiles.length || pollScheduled) + return; + pollScheduled = host.setTimeout(pollQueue, PollingInterval.High); + } + } /* @internal */ function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) { var cache = new ts.Map(); @@ -7022,8 +7114,9 @@ var ts; } /*@internal*/ function createSystemWatchFunctions(_a) { - var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory; + var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, defaultWatchFileKind = _a.defaultWatchFileKind; var dynamicPollingWatchFile; + var fixedChunkSizePollingWatchFile; var nonPollingWatchFile; var hostRecursiveDirectoryWatcher; return { @@ -7040,6 +7133,8 @@ var ts; return pollingWatchFile(fileName, callback, pollingInterval, /*options*/ undefined); case ts.WatchFileKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, /*options*/ undefined); + case ts.WatchFileKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); @@ -7053,8 +7148,10 @@ var ts; } } function ensureDynamicPollingWatchFile() { - return dynamicPollingWatchFile || - (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + return dynamicPollingWatchFile || (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); + } + function ensureFixedChunkSizePollingWatchFile() { + return fixedChunkSizePollingWatchFile || (fixedChunkSizePollingWatchFile = createFixedChunkSizePollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout })); } function updateOptionsForWatchFile(options, useNonPollingWatchers) { if (options && options.watchFile !== undefined) @@ -7080,7 +7177,7 @@ var ts; // Use notifications from FS to watch with falling back to fs.watchFile generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) : // Default to do not use fixed polling interval - { watchFile: ts.WatchFileKind.FixedPollingInterval }; + { watchFile: (defaultWatchFileKind === null || defaultWatchFileKind === void 0 ? void 0 : defaultWatchFileKind()) || ts.WatchFileKind.FixedPollingInterval }; } } function generateWatchFileOptions(watchFile, fallbackPolling, options) { @@ -7121,6 +7218,10 @@ var ts; case ts.WatchDirectoryKind.DynamicPriorityPolling: return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, /*options*/ undefined); + case ts.WatchDirectoryKind.FixedChunkSizePolling: + return ensureFixedChunkSizePollingWatchFile()(directoryName, function () { return callback(directoryName); }, + /* pollingInterval */ undefined, + /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: @@ -7199,13 +7300,13 @@ var ts; } var activeSession; var profilePath = "./profile.cpuprofile"; - var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; 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 fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin"); var getCurrentDirectory = ts.memoize(function () { return process.cwd(); }); var _c = createSystemWatchFunctions({ @@ -7226,6 +7327,7 @@ var ts; tscWatchFile: process.env.TSC_WATCHFILE, useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER, tscWatchDirectory: process.env.TSC_WATCHDIRECTORY, + defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); }, }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory; var nodeSystem = { args: process.argv.slice(2), @@ -7903,7 +8005,7 @@ var ts; A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_1166", "A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type."), A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), @@ -7963,7 +8065,7 @@ var ts; A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration_1231", "An export assignment must be at the top level of a file or module declaration."), An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), @@ -7989,6 +8091,7 @@ var ts; 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."), + A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration: diag(1258, ts.DiagnosticCategory.Error, "A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration_1258", "A default export must be at the top level of a file or module declaration."), Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), Already_included_file_name_0_differs_from_file_name_1_only_in_casing: diag(1261, ts.DiagnosticCategory.Error, "Already_included_file_name_0_differs_from_file_name_1_only_in_casing_1261", "Already included file name '{0}' differs from file name '{1}' only in casing."), @@ -8075,7 +8178,7 @@ var ts; 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."), + 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."), 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}'"), @@ -8117,6 +8220,7 @@ var ts; 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."), + 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."), 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), @@ -8202,8 +8306,7 @@ var ts; 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."), - Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), - get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), + 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."), @@ -8266,7 +8369,7 @@ var ts; Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: diag(2443, ts.DiagnosticCategory.Error, "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'."), Property_0_is_protected_in_type_1_but_public_in_type_2: diag(2444, ts.DiagnosticCategory.Error, "Property_0_is_protected_in_type_1_but_public_in_type_2_2444", "Property '{0}' is protected in type '{1}' but public in type '{2}'."), Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: diag(2445, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses_2445", "Property '{0}' is protected and only accessible within class '{1}' and its subclasses."), - Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'."), + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_class_2: diag(2446, ts.DiagnosticCategory.Error, "Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1_This_is_an_instance_of_cl_2446", "Property '{0}' is protected and only accessible through an instance of class '{1}'. This is an instance of class '{2}'."), The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead: diag(2447, ts.DiagnosticCategory.Error, "The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead_2447", "The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead."), Block_scoped_variable_0_used_before_its_declaration: diag(2448, ts.DiagnosticCategory.Error, "Block_scoped_variable_0_used_before_its_declaration_2448", "Block-scoped variable '{0}' used before its declaration."), Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."), @@ -8366,14 +8469,13 @@ var ts; The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."), Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."), Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."), - Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the `lib` compiler option to '{2}' or later."), + Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_2_or_later: diag(2550, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Do_you_need_to_change_your_target_library_Try_changing_the_lib_c_2550", "Property '{0}' does not exist on type '{1}'. Do you need to change your target library? Try changing the 'lib' compiler option to '{2}' or later."), Property_0_does_not_exist_on_type_1_Did_you_mean_2: diag(2551, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_2_2551", "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?"), Cannot_find_name_0_Did_you_mean_1: diag(2552, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Did_you_mean_1_2552", "Cannot find name '{0}'. Did you mean '{1}'?"), Computed_values_are_not_permitted_in_an_enum_with_string_valued_members: diag(2553, ts.DiagnosticCategory.Error, "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553", "Computed values are not permitted in an enum with string valued members."), Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."), Expected_at_least_0_arguments_but_got_1: diag(2555, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_2555", "Expected at least {0} arguments, but got {1}."), - Expected_0_arguments_but_got_1_or_more: diag(2556, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_or_more_2556", "Expected {0} arguments, but got {1} or more."), - Expected_at_least_0_arguments_but_got_1_or_more: diag(2557, ts.DiagnosticCategory.Error, "Expected_at_least_0_arguments_but_got_1_or_more_2557", "Expected at least {0} arguments, but got {1} or more."), + A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter: diag(2556, ts.DiagnosticCategory.Error, "A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter_2556", "A spread argument must either have a tuple type or be passed to a rest parameter."), Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), @@ -8396,17 +8498,17 @@ var ts; Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`."), - 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."), + 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."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add `node` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add `jquery` to the types field in your tsconfig."), - Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode_and_then_add_node_to_the_types_field_in_your_tsconfig: diag(2591, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashno_2591", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slash_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i --save-dev @types/jquery` and then add 'jquery' to the types field in your tsconfig."), + Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_types_Slashjest_or_npm_i_save_dev_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_save_dev_type_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig."), This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."), _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."), _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."), @@ -8439,6 +8541,12 @@ var ts; Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target: diag(2625, ts.DiagnosticCategory.Error, "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625", "Variadic element at position {0} in source does not match element at position {1} in target."), Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target: diag(2626, ts.DiagnosticCategory.Error, "Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target_2626", "Type at position {0} in source is not compatible with type at position {1} in target."), Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target: diag(2627, ts.DiagnosticCategory.Error, "Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target_2627", "Type at positions {0} through {1} in source is not compatible with type at position {2} in target."), + Cannot_assign_to_0_because_it_is_an_enum: diag(2628, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_enum_2628", "Cannot assign to '{0}' because it is an enum."), + Cannot_assign_to_0_because_it_is_a_class: diag(2629, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_class_2629", "Cannot assign to '{0}' because it is a class."), + Cannot_assign_to_0_because_it_is_a_function: diag(2630, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_function_2630", "Cannot assign to '{0}' because it is a function."), + Cannot_assign_to_0_because_it_is_a_namespace: diag(2631, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_a_namespace_2631", "Cannot assign to '{0}' because it is a namespace."), + Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."), + JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -8485,7 +8593,7 @@ var ts; Namespace_0_has_no_exported_member_1: diag(2694, ts.DiagnosticCategory.Error, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."), Left_side_of_comma_operator_is_unused_and_has_no_side_effects: diag(2695, ts.DiagnosticCategory.Error, "Left_side_of_comma_operator_is_unused_and_has_no_side_effects_2695", "Left side of comma operator is unused and has no side effects.", /*reportsUnnecessary*/ true), The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead: diag(2696, ts.DiagnosticCategory.Error, "The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead_2696", "The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead?"), - An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), + An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2697, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), Spread_types_may_only_be_created_from_object_types: diag(2698, ts.DiagnosticCategory.Error, "Spread_types_may_only_be_created_from_object_types_2698", "Spread types may only be created from object types."), Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1: diag(2699, ts.DiagnosticCategory.Error, "Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1_2699", "Static property '{0}' conflicts with built-in property 'Function.{0}' of constructor function '{1}'."), Rest_types_may_only_be_created_from_object_types: diag(2700, ts.DiagnosticCategory.Error, "Rest_types_may_only_be_created_from_object_types_2700", "Rest types may only be created from object types."), @@ -8493,14 +8601,14 @@ var ts; _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: diag(2702, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", "'{0}' only refers to a type, but is being used as a namespace here."), The_operand_of_a_delete_operator_must_be_a_property_reference: diag(2703, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", "The operand of a 'delete' operator must be a property reference."), The_operand_of_a_delete_operator_cannot_be_a_read_only_property: diag(2704, ts.DiagnosticCategory.Error, "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", "The operand of a 'delete' operator cannot be a read-only property."), - 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + 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: diag(2705, ts.DiagnosticCategory.Error, "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), Required_type_parameters_may_not_follow_optional_type_parameters: diag(2706, ts.DiagnosticCategory.Error, "Required_type_parameters_may_not_follow_optional_type_parameters_2706", "Required type parameters may not follow optional type parameters."), Generic_type_0_requires_between_1_and_2_type_arguments: diag(2707, ts.DiagnosticCategory.Error, "Generic_type_0_requires_between_1_and_2_type_arguments_2707", "Generic type '{0}' requires between {1} and {2} type arguments."), Cannot_use_namespace_0_as_a_value: diag(2708, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_value_2708", "Cannot use namespace '{0}' as a value."), Cannot_use_namespace_0_as_a_type: diag(2709, ts.DiagnosticCategory.Error, "Cannot_use_namespace_0_as_a_type_2709", "Cannot use namespace '{0}' as a type."), _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: diag(2710, ts.DiagnosticCategory.Error, "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", "'{0}' are specified twice. The attribute named '{0}' will be overwritten."), - A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), - A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), + A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your '--lib' option."), + A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option."), 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: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "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}\"]'?"), The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor: diag(2715, ts.DiagnosticCategory.Error, "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715", "Abstract property '{0}' in class '{1}' cannot be accessed in the constructor."), @@ -8562,7 +8670,7 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), - This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_2774", "This condition will always return true since this function is always defined. Did you mean to call it instead?"), Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), @@ -8589,6 +8697,18 @@ var ts; The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."), Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."), Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."), + This_condition_will_always_return_true_since_this_0_is_always_defined: diag(2801, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_this_0_is_always_defined_2801", "This condition will always return true since this '{0}' is always defined."), + Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."), + Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."), + Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."), + 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: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "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."), + Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."), + This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."), + A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"), + Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."), + Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."), + Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"), + Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."), 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}'."), @@ -8683,6 +8803,11 @@ var ts; Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0: diag(4111, ts.DiagnosticCategory.Error, "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111", "Property '{0}' comes from an index signature, so it must be accessed with ['{0}']."), + This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class: diag(4112, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another__4112", "This member cannot have an 'override' modifier because its containing class '{0}' does not extend another class."), + This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0: diag(4113, ts.DiagnosticCategory.Error, "This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_4113", "This member cannot have an 'override' modifier because it is not declared in the base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0: diag(4114, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0_4114", "This member must have an 'override' modifier because it overrides a member in the base class '{0}'."), + This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0: diag(4115, ts.DiagnosticCategory.Error, "This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0_4115", "This parameter property must have an 'override' modifier because it overrides a member in base class '{0}'."), + This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0: diag(4116, ts.DiagnosticCategory.Error, "This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared__4116", "This member must have an 'override' modifier because it overrides an abstract method that is declared in the base class '{0}'."), 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}'."), @@ -8717,7 +8842,7 @@ var ts; Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext: diag(5071, ts.DiagnosticCategory.Error, "Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_5071", "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'."), Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."), Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), - Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), + Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option '--tsBuildInfoFile' is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Unknown_build_option_0_Did_you_mean_1: diag(5077, ts.DiagnosticCategory.Error, "Unknown_build_option_0_Did_you_mean_1_5077", "Unknown build option '{0}'. Did you mean '{1}'?"), @@ -8730,11 +8855,14 @@ var ts; Tuple_members_must_all_have_names_or_all_not_have_names: diag(5084, ts.DiagnosticCategory.Error, "Tuple_members_must_all_have_names_or_all_not_have_names_5084", "Tuple members must all have names or all not have names."), A_tuple_member_cannot_be_both_optional_and_rest: diag(5085, ts.DiagnosticCategory.Error, "A_tuple_member_cannot_be_both_optional_and_rest_5085", "A tuple member cannot be both optional and rest."), A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type: diag(5086, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_c_5086", "A labeled tuple element is declared as optional with a question mark after the name and before the colon, rather than after the type."), - A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a `...` before the name, rather than before the type."), + A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type: diag(5087, ts.DiagnosticCategory.Error, "A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type_5087", "A labeled tuple element is declared as rest with a '...' before the name, rather than before the type."), The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary: diag(5088, ts.DiagnosticCategory.Error, "The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialize_5088", "The inferred type of '{0}' references a type with a cyclic structure which cannot be trivially serialized. A type annotation is necessary."), Option_0_cannot_be_specified_when_option_jsx_is_1: diag(5089, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_jsx_is_1_5089", "Option '{0}' cannot be specified when option 'jsx' is '{1}'."), Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash: diag(5090, ts.DiagnosticCategory.Error, "Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash_5090", "Non-relative paths are not allowed when 'baseUrl' is not set. Did you forget a leading './'?"), Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled: diag(5091, ts.DiagnosticCategory.Error, "Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled_5091", "Option 'preserveConstEnums' cannot be disabled when 'isolatedModules' is enabled."), + 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'."), 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."), @@ -8750,7 +8878,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."), - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'."), + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'."), Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), @@ -8945,9 +9073,9 @@ var ts; Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."), - Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), - Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), - Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), + Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory: diag(6225, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_Dynami_6225", "Specify strategy for watching file: 'FixedPollingInterval' (default), 'PriorityPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling', 'UseFsEvents', 'UseFsEventsOnParentDirectory'."), + Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling', 'FixedChunkSizePolling'."), + Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority', 'FixedChunkSize'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, ts.DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."), Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), @@ -8958,7 +9086,11 @@ var ts; Disable_loading_referenced_projects: diag(6235, ts.DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."), Arguments_for_the_rest_parameter_0_were_not_provided: diag(6236, ts.DiagnosticCategory.Error, "Arguments_for_the_rest_parameter_0_were_not_provided_6236", "Arguments for the rest parameter '{0}' were not provided."), Generates_an_event_trace_and_a_list_of_types: diag(6237, ts.DiagnosticCategory.Message, "Generates_an_event_trace_and_a_list_of_types_6237", "Generates an event trace and a list of types."), - Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the `jsx` and `jsxs` factory functions from. eg, react"), + Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react: diag(6238, ts.DiagnosticCategory.Error, "Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react_6238", "Specify the module specifier to be used to import the 'jsx' and 'jsxs' factory functions from. eg, react"), + File_0_exists_according_to_earlier_cached_lookups: diag(6239, ts.DiagnosticCategory.Message, "File_0_exists_according_to_earlier_cached_lookups_6239", "File '{0}' exists according to earlier cached lookups."), + File_0_does_not_exist_according_to_earlier_cached_lookups: diag(6240, ts.DiagnosticCategory.Message, "File_0_does_not_exist_according_to_earlier_cached_lookups_6240", "File '{0}' does not exist according to earlier cached lookups."), + Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1: diag(6241, ts.DiagnosticCategory.Message, "Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1_6241", "Resolution for type reference directive '{0}' was found in cache from location '{1}'."), + Resolving_type_reference_directive_0_containing_file_1: diag(6242, ts.DiagnosticCategory.Message, "Resolving_type_reference_directive_0_containing_file_1_6242", "======== Resolving type reference directive '{0}', containing file '{1}'. ========"), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -9006,14 +9138,16 @@ var ts; _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_native_implementation_of_the_Web_Performance_API_could_not_be_found: diag(6386, ts.DiagnosticCategory.Message, "Performance_timings_for_diagnostics_or_extendedDiagnostics_are_not_available_in_this_session_A_nativ_6386", "Performance timings for '--diagnostics' or '--extendedDiagnostics' are not available in this session. A native implementation of the Web Performance API could not be found."), The_signature_0_of_1_is_deprecated: diag(6387, ts.DiagnosticCategory.Suggestion, "The_signature_0_of_1_is_deprecated_6387", "The signature '{0}' of '{1}' is deprecated.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ undefined, /*reportsDeprecated*/ true), + Project_0_is_being_forcibly_rebuilt: diag(6388, ts.DiagnosticCategory.Message, "Project_0_is_being_forcibly_rebuilt_6388", "Project '{0}' is being forcibly rebuilt"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option: diag(6504, ts.DiagnosticCategory.Error, "File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option_6504", "File '{0}' is a JavaScript file. Did you mean to enable the 'allowJs' option?"), Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, ts.DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."), - Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6803, ts.DiagnosticCategory.Error, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803", "Require undeclared properties from index signatures to use element accesses."), Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"), + Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier: diag(6801, ts.DiagnosticCategory.Message, "Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier_6801", "Ensure overriding members in derived classes are marked with an 'override' modifier."), + Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6802, ts.DiagnosticCategory.Message, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6802", "Require undeclared properties from index signatures to use element accesses."), 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."), @@ -9046,7 +9180,7 @@ var ts; Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports: diag(7037, ts.DiagnosticCategory.Message, "Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for__7037", "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'."), Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime_Consider_using_a_default_import_or_import_require_here_instead: diag(7038, ts.DiagnosticCategory.Message, "Type_originates_at_this_import_A_namespace_style_import_cannot_be_called_or_constructed_and_will_cau_7038", "Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead."), Mapped_object_type_implicitly_has_an_any_template_type: diag(7039, ts.DiagnosticCategory.Error, "Mapped_object_type_implicitly_has_an_any_template_type_7039", "Mapped object type implicitly has an 'any' template type."), - 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: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}`"), + 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: diag(7040, ts.DiagnosticCategory.Error, "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040", "If the '{0}' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'"), The_containing_arrow_function_captures_the_global_value_of_this: diag(7041, ts.DiagnosticCategory.Error, "The_containing_arrow_function_captures_the_global_value_of_this_7041", "The containing arrow function captures the global value of 'this'."), Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used: diag(7042, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used_7042", "Module '{0}' was resolved to '{1}', but '--resolveJsonModule' is not used."), Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage: diag(7043, ts.DiagnosticCategory.Suggestion, "Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage_7043", "Variable '{0}' implicitly has an '{1}' type, but a better type may be inferred from usage."), @@ -9086,7 +9220,7 @@ var ts; JSDoc_0_is_not_attached_to_a_class: diag(8022, ts.DiagnosticCategory.Error, "JSDoc_0_is_not_attached_to_a_class_8022", "JSDoc '@{0}' is not attached to a class."), JSDoc_0_1_does_not_match_the_extends_2_clause: diag(8023, ts.DiagnosticCategory.Error, "JSDoc_0_1_does_not_match_the_extends_2_clause_8023", "JSDoc '@{0} {1}' does not match the 'extends {2}' clause."), JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name: diag(8024, ts.DiagnosticCategory.Error, "JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_8024", "JSDoc '@param' tag has name '{0}', but there is no parameter with that name."), - Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one `@augments` or `@extends` tag."), + Class_declarations_cannot_have_more_than_one_augments_or_extends_tag: diag(8025, ts.DiagnosticCategory.Error, "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025", "Class declarations cannot have more than one '@augments' or '@extends' tag."), Expected_0_type_arguments_provide_these_with_an_extends_tag: diag(8026, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_provide_these_with_an_extends_tag_8026", "Expected {0} type arguments; provide these with an '@extends' tag."), Expected_0_1_type_arguments_provide_these_with_an_extends_tag: diag(8027, ts.DiagnosticCategory.Error, "Expected_0_1_type_arguments_provide_these_with_an_extends_tag_8027", "Expected {0}-{1} type arguments; provide these with an '@extends' tag."), JSDoc_may_only_appear_in_the_last_parameter_of_a_signature: diag(8028, ts.DiagnosticCategory.Error, "JSDoc_may_only_appear_in_the_last_parameter_of_a_signature_8028", "JSDoc '...' may only appear in the last parameter of a signature."), @@ -9331,6 +9465,10 @@ var ts; Add_all_missing_function_declarations: diag(95157, ts.DiagnosticCategory.Message, "Add_all_missing_function_declarations_95157", "Add all missing function declarations"), Method_not_implemented: diag(95158, ts.DiagnosticCategory.Message, "Method_not_implemented_95158", "Method not implemented."), Function_not_implemented: diag(95159, ts.DiagnosticCategory.Message, "Function_not_implemented_95159", "Function not implemented."), + Add_override_modifier: diag(95160, ts.DiagnosticCategory.Message, "Add_override_modifier_95160", "Add 'override' modifier"), + Remove_override_modifier: diag(95161, ts.DiagnosticCategory.Message, "Remove_override_modifier_95161", "Remove 'override' modifier"), + Add_all_missing_override_modifiers: diag(95162, ts.DiagnosticCategory.Message, "Add_all_missing_override_modifiers_95162", "Add all missing 'override' modifiers"), + Remove_all_unnecessary_override_modifiers: diag(95163, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_override_modifiers_95163", "Remove all unnecessary 'override' modifiers"), 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?"), @@ -9345,8 +9483,6 @@ var ts; The_shadowing_declaration_of_0_is_defined_here: diag(18017, ts.DiagnosticCategory.Error, "The_shadowing_declaration_of_0_is_defined_here_18017", "The shadowing declaration of '{0}' is defined here"), The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here: diag(18018, ts.DiagnosticCategory.Error, "The_declaration_of_0_that_you_probably_intended_to_use_is_defined_here_18018", "The declaration of '{0}' that you probably intended to use is defined here"), _0_modifier_cannot_be_used_with_a_private_identifier: diag(18019, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_private_identifier_18019", "'{0}' modifier cannot be used with a private identifier."), - A_method_cannot_be_named_with_a_private_identifier: diag(18022, ts.DiagnosticCategory.Error, "A_method_cannot_be_named_with_a_private_identifier_18022", "A method cannot be named with a private identifier."), - An_accessor_cannot_be_named_with_a_private_identifier: diag(18023, ts.DiagnosticCategory.Error, "An_accessor_cannot_be_named_with_a_private_identifier_18023", "An accessor cannot be named with a private identifier."), An_enum_member_cannot_be_named_with_a_private_identifier: diag(18024, ts.DiagnosticCategory.Error, "An_enum_member_cannot_be_named_with_a_private_identifier_18024", "An enum member cannot be named with a private identifier."), can_only_be_used_at_the_start_of_a_file: diag(18026, ts.DiagnosticCategory.Error, "can_only_be_used_at_the_start_of_a_file_18026", "'#!' can only be used at the start of a file."), Compiler_reserves_name_0_when_emitting_private_identifier_downlevel: diag(18027, ts.DiagnosticCategory.Error, "Compiler_reserves_name_0_when_emitting_private_identifier_downlevel_18027", "Compiler reserves name '{0}' when emitting private identifier downlevel."), @@ -9358,6 +9494,7 @@ var ts; Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead: diag(18033, ts.DiagnosticCategory.Error, "Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033", "Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead."), Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compiler_option_is_specified_e_g_Fragment: diag(18034, ts.DiagnosticCategory.Message, "Specify_the_JSX_fragment_factory_function_to_use_when_targeting_react_JSX_emit_with_jsxFactory_compi_18034", "Specify the JSX fragment factory function to use when targeting 'react' JSX emit with 'jsxFactory' compiler option is specified, e.g. 'Fragment'."), Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name: diag(18035, ts.DiagnosticCategory.Error, "Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name_18035", "Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name."), + Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator: diag(18036, ts.DiagnosticCategory.Error, "Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_dec_18036", "Class decorators can't be used with static private identifier. Consider removing the experimental decorator."), }; })(ts || (ts = {})); var ts; @@ -9425,6 +9562,7 @@ var ts; _a.private = 120 /* PrivateKeyword */, _a.protected = 121 /* ProtectedKeyword */, _a.public = 122 /* PublicKeyword */, + _a.override = 156 /* OverrideKeyword */, _a.readonly = 142 /* ReadonlyKeyword */, _a.require = 143 /* RequireKeyword */, _a.global = 154 /* GlobalKeyword */, @@ -9451,7 +9589,7 @@ var ts; _a.yield = 124 /* YieldKeyword */, _a.async = 129 /* AsyncKeyword */, _a.await = 130 /* AwaitKeyword */, - _a.of = 156 /* OfKeyword */, + _a.of = 157 /* OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj)); var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 77 /* CaretEqualsToken */, "||=": 74 /* BarBarEqualsToken */, "&&=": 75 /* AmpersandAmpersandEqualsToken */, "??=": 76 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ }))); @@ -9767,11 +9905,11 @@ var ts; } ts.couldStartTrivia = couldStartTrivia; /* @internal */ - function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) { - if (stopAtComments === void 0) { stopAtComments = false; } + function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments, inJSDoc) { if (ts.positionIsSynthesized(pos)) { return pos; } + var canConsumeStar = false; // Keep in sync with couldStartTrivia while (true) { var ch = text.charCodeAt(pos); @@ -9786,6 +9924,7 @@ var ts; if (stopAfterLineBreak) { return pos; } + canConsumeStar = !!inJSDoc; continue; case 9 /* tab */: case 11 /* verticalTab */: @@ -9805,6 +9944,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { @@ -9816,6 +9956,7 @@ var ts; } pos++; } + canConsumeStar = false; continue; } break; @@ -9825,12 +9966,21 @@ var ts; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); + canConsumeStar = false; continue; } break; case 35 /* hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); + canConsumeStar = false; + continue; + } + break; + case 42 /* asterisk */: + if (canConsumeStar) { + pos++; + canConsumeStar = false; continue; } break; @@ -11294,9 +11444,10 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ true); } - function reScanJsxToken() { + function reScanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } pos = tokenPos = startPos; - return token = scanJsxToken(); + return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { if (token === 47 /* LessThanLessThanToken */) { @@ -11310,7 +11461,8 @@ var ts; pos = tokenPos + 1; return token = 57 /* QuestionToken */; } - function scanJsxToken() { + function scanJsxToken(allowMultilineJsxText) { + if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { return token = 1 /* EndOfFileToken */; @@ -11330,15 +11482,9 @@ var ts; } // First non-whitespace character on this line. var firstNonWhitespace = 0; - var lastNonWhitespace = -1; // These initial values are special because the first line is: // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { - // We want to keep track of the last non-whitespace (but including - // newlines character for hitting the end of the JSX Text region) - if (!isWhiteSpaceSingleLine(char)) { - lastNonWhitespace = pos; - } char = text.charCodeAt(pos); if (char === 123 /* openBrace */) { break; @@ -11356,8 +11502,6 @@ var ts; if (char === 125 /* closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } - if (lastNonWhitespace > 0) - lastNonWhitespace++; // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. // i.e (- : whitespace) //
---- @@ -11367,13 +11511,17 @@ var ts; if (isLineBreak(char) && firstNonWhitespace === 0) { firstNonWhitespace = -1; } + else if (!allowMultilineJsxText && isLineBreak(char) && firstNonWhitespace > 0) { + // Stop JsxText on each line during formatting. This allows the formatter to + // indent each line correctly. + break; + } else if (!isWhiteSpaceLike(char)) { firstNonWhitespace = pos; } pos++; } - var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace; - tokenValue = text.substring(startPos, endPosition); + tokenValue = text.substring(startPos, pos); return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that @@ -11396,6 +11544,7 @@ var ts; tokenValue += ":"; pos++; namespaceSeparator = true; + token = 78 /* Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -11652,6 +11801,8 @@ var ts; switch (options.target) { case 99 /* ESNext */: return "lib.esnext.full.d.ts"; + case 8 /* ES2021 */: + return "lib.es2021.full.d.ts"; case 7 /* ES2020 */: return "lib.es2020.full.d.ts"; case 6 /* ES2019 */: @@ -11870,9 +12021,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 159 /* TypeParameter */) { + if (d && d.kind === 160 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 253 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 254 /* InterfaceDeclaration */) { return current; } } @@ -11880,7 +12031,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 166 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 167 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -11910,14 +12061,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 249 /* VariableDeclaration */) { + if (node.kind === 250 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 250 /* VariableDeclarationList */) { + if (node && node.kind === 251 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 232 /* VariableStatement */) { + if (node && node.kind === 233 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12068,7 +12219,7 @@ var ts; } ts.idText = idText; function symbolName(symbol) { - if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (symbol.valueDeclaration && isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return idText(symbol.valueDeclaration.name); } return unescapeLeadingUnderscores(symbol.escapedName); @@ -12090,30 +12241,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 216 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { + if (expr.kind === 217 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return expr.name; - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 207 /* ParenthesizedExpression */: { + case 208 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 245 /* LabeledStatement */: { + case 246 /* LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12150,16 +12301,16 @@ var ts; switch (declaration.kind) { case 78 /* Identifier */: return declaration; - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: { + case 337 /* JSDocPropertyTag */: + case 330 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 157 /* QualifiedName */) { + if (name.kind === 158 /* QualifiedName */) { return name.right; } break; } - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 204 /* CallExpression */: + case 217 /* BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: @@ -12175,15 +12326,15 @@ var ts; return undefined; } } - case 331 /* JSDocTypedefTag */: + case 335 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 325 /* JSDocEnumTag */: + case 329 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 266 /* ExportAssignment */: { + case 267 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -12196,7 +12347,7 @@ var ts; if (declaration === undefined) return undefined; return getNonAssignedNameOfDeclaration(declaration) || - (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); + (ts.isFunctionExpression(declaration) || ts.isArrowFunction(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined); } ts.getNameOfDeclaration = getNameOfDeclaration; /*@internal*/ @@ -12349,6 +12500,10 @@ var ts; return getFirstJSDocTag(node, ts.isJSDocReadonlyTag, /*noCache*/ true); } ts.getJSDocReadonlyTagNoCache = getJSDocReadonlyTagNoCache; + function getJSDocOverrideTagNoCache(node) { + return getFirstJSDocTag(node, ts.isJSDocOverrideTag, /*noCache*/ true); + } + ts.getJSDocOverrideTagNoCache = getJSDocOverrideTagNoCache; /** Gets the JSDoc deprecated tag for the node if present */ function getJSDocDeprecatedTag(node) { return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag); @@ -12469,6 +12624,14 @@ var ts; return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; }); } ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind; + /** Gets the text of a jsdoc comment, flattening links to their text. */ + function getTextOfJSDocComment(comment) { + return typeof comment === "string" ? comment + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { + return c.kind === 313 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}"; + }).join(""); + } + ts.getTextOfJSDocComment = getTextOfJSDocComment; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. @@ -12478,7 +12641,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 311 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 312 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -12504,13 +12667,13 @@ var ts; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region - function isIdentifierOrPrivateIdentifier(node) { + function isMemberName(node) { return node.kind === 78 /* Identifier */ || node.kind === 79 /* PrivateIdentifier */; } - ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier; + ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */ || node.kind === 167 /* GetAccessor */; + return node.kind === 169 /* SetAccessor */ || node.kind === 168 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { @@ -12528,10 +12691,10 @@ var ts; function isOptionalChain(node) { var kind = node.kind; return !!(node.flags & 32 /* OptionalChain */) && - (kind === 201 /* PropertyAccessExpression */ - || kind === 202 /* ElementAccessExpression */ - || kind === 203 /* CallExpression */ - || kind === 225 /* NonNullExpression */); + (kind === 202 /* PropertyAccessExpression */ + || kind === 203 /* ElementAccessExpression */ + || kind === 204 /* CallExpression */ + || kind === 226 /* NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -12566,7 +12729,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 217 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -12583,17 +12746,17 @@ var ts; } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 241 /* BreakStatement */ || node.kind === 240 /* ContinueStatement */; + return node.kind === 242 /* BreakStatement */ || node.kind === 241 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 269 /* NamespaceExport */ || node.kind === 268 /* NamedExports */; + return node.kind === 270 /* NamespaceExport */ || node.kind === 269 /* NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: + case 295 /* UnparsedText */: + case 296 /* UnparsedInternalText */: return true; default: return false; @@ -12602,12 +12765,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 292 /* UnparsedPrologue */ || - node.kind === 296 /* UnparsedSyntheticReference */; + node.kind === 293 /* UnparsedPrologue */ || + node.kind === 297 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 333 /* JSDocPropertyTag */ || node.kind === 326 /* JSDocParameterTag */; + return node.kind === 337 /* JSDocPropertyTag */ || node.kind === 330 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -12623,16 +12786,25 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 157 /* FirstNode */; + return kind >= 158 /* FirstNode */; } ts.isNodeKind = isNodeKind; + /** + * True if kind is of some token syntax kind. + * For example, this is true for an IfKeyword but not for an IfStatement. + * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. + */ + function isTokenKind(kind) { + return kind >= 0 /* FirstToken */ && kind <= 157 /* LastToken */; + } + ts.isTokenKind = isTokenKind; /** * True if node is of some token syntax kind. * For example, this is true for an IfKeyword but not for an IfStatement. * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 156 /* LastToken */; + return isTokenKind(n.kind); } ts.isToken = isToken; // Node Arrays @@ -12673,13 +12845,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 266 /* ImportSpecifier */: + case 271 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: return node.parent.isTypeOnly; - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportClause */: + case 261 /* ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -12698,10 +12870,10 @@ var ts; ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers /*@internal*/ - function isPrivateIdentifierPropertyDeclaration(node) { - return ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name); + function isPrivateIdentifierClassElementDeclaration(node) { + return (ts.isPropertyDeclaration(node) || isMethodOrAccessor(node)) && ts.isPrivateIdentifier(node.name); } - ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration; + ts.isPrivateIdentifierClassElementDeclaration = isPrivateIdentifierClassElementDeclaration; /*@internal*/ function isPrivateIdentifierPropertyAccessExpression(node) { return ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name); @@ -12722,6 +12894,7 @@ var ts; case 121 /* ProtectedKeyword */: case 142 /* ReadonlyKeyword */: case 123 /* StaticKeyword */: + case 156 /* OverrideKeyword */: return true; } return false; @@ -12729,12 +12902,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 92 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 123 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 123 /* StaticKeyword */ || idToken === 156 /* OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -12743,7 +12916,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 157 /* QualifiedName */ + return kind === 158 /* QualifiedName */ || kind === 78 /* Identifier */; } ts.isEntityName = isEntityName; @@ -12753,19 +12926,19 @@ var ts; || kind === 79 /* PrivateIdentifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 158 /* ComputedPropertyName */; + || kind === 159 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 78 /* Identifier */ - || kind === 196 /* ObjectBindingPattern */ - || kind === 197 /* ArrayBindingPattern */; + || kind === 197 /* ObjectBindingPattern */ + || kind === 198 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions function isFunctionLike(node) { - return node && isFunctionLikeKind(node.kind); + return !!node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; /* @internal */ @@ -12775,13 +12948,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 252 /* FunctionDeclaration */: + case 166 /* MethodDeclaration */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return true; default: return false; @@ -12790,14 +12963,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 175 /* ConstructorType */: + case 165 /* MethodSignature */: + case 170 /* CallSignature */: + case 315 /* JSDocSignature */: + case 171 /* ConstructSignature */: + case 172 /* IndexSignature */: + case 175 /* FunctionType */: + case 309 /* JSDocFunctionType */: + case 176 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -12812,29 +12985,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 163 /* PropertyDeclaration */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 229 /* SemicolonClassElement */; + return kind === 167 /* Constructor */ + || kind === 164 /* PropertyDeclaration */ + || kind === 166 /* MethodDeclaration */ + || kind === 168 /* GetAccessor */ + || kind === 169 /* SetAccessor */ + || kind === 172 /* IndexSignature */ + || kind === 230 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */); + return node && (node.kind === 253 /* ClassDeclaration */ || node.kind === 222 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */); + return node && (node.kind === 168 /* GetAccessor */ || node.kind === 169 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return true; default: return false; @@ -12844,11 +13017,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 170 /* ConstructSignature */ - || kind === 169 /* CallSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */ - || kind === 171 /* IndexSignature */; + return kind === 171 /* ConstructSignature */ + || kind === 170 /* CallSignature */ + || kind === 163 /* PropertySignature */ + || kind === 165 /* MethodSignature */ + || kind === 172 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -12857,12 +13030,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 288 /* PropertyAssignment */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 290 /* SpreadAssignment */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 289 /* PropertyAssignment */ + || kind === 290 /* ShorthandPropertyAssignment */ + || kind === 291 /* SpreadAssignment */ + || kind === 166 /* MethodDeclaration */ + || kind === 168 /* GetAccessor */ + || kind === 169 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -12877,8 +13050,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: return true; } return false; @@ -12889,8 +13062,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 197 /* ArrayBindingPattern */ - || kind === 196 /* ObjectBindingPattern */; + return kind === 198 /* ArrayBindingPattern */ + || kind === 197 /* ObjectBindingPattern */; } return false; } @@ -12898,15 +13071,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 199 /* ArrayLiteralExpression */ - || kind === 200 /* ObjectLiteralExpression */; + return kind === 200 /* ArrayLiteralExpression */ + || kind === 201 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 198 /* BindingElement */ - || kind === 222 /* OmittedExpression */; + return kind === 199 /* BindingElement */ + || kind === 223 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -12915,9 +13088,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 250 /* VariableDeclaration */: + case 161 /* Parameter */: + case 199 /* BindingElement */: return true; } return false; @@ -12938,8 +13111,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 197 /* ObjectBindingPattern */: + case 201 /* ObjectLiteralExpression */: return true; } return false; @@ -12951,8 +13124,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 198 /* ArrayBindingPattern */: + case 200 /* ArrayLiteralExpression */: return true; } return false; @@ -12961,26 +13134,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */ - || kind === 195 /* ImportType */; + return kind === 202 /* PropertyAccessExpression */ + || kind === 158 /* QualifiedName */ + || kind === 196 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 201 /* PropertyAccessExpression */ - || kind === 157 /* QualifiedName */; + return kind === 202 /* PropertyAccessExpression */ + || kind === 158 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: + case 276 /* JsxOpeningElement */: + case 275 /* JsxSelfClosingElement */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: + case 206 /* TaggedTemplateExpression */: + case 162 /* Decorator */: return true; default: return false; @@ -12988,12 +13161,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 203 /* CallExpression */ || node.kind === 204 /* NewExpression */; + return node.kind === 204 /* CallExpression */ || node.kind === 205 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 218 /* TemplateExpression */ + return kind === 219 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -13004,33 +13177,33 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 204 /* NewExpression */: - case 203 /* CallExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 205 /* TaggedTemplateExpression */: - case 199 /* ArrayLiteralExpression */: - case 207 /* ParenthesizedExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: + case 205 /* NewExpression */: + case 204 /* CallExpression */: + case 274 /* JsxElement */: + case 275 /* JsxSelfClosingElement */: + case 278 /* JsxFragment */: + case 206 /* TaggedTemplateExpression */: + case 200 /* ArrayLiteralExpression */: + case 208 /* ParenthesizedExpression */: + case 201 /* ObjectLiteralExpression */: + case 222 /* ClassExpression */: + case 209 /* FunctionExpression */: case 78 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: + case 219 /* TemplateExpression */: case 94 /* FalseKeyword */: case 103 /* NullKeyword */: case 107 /* ThisKeyword */: case 109 /* TrueKeyword */: case 105 /* SuperKeyword */: - case 225 /* NonNullExpression */: - case 226 /* MetaProperty */: + case 226 /* NonNullExpression */: + case 227 /* MetaProperty */: case 99 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -13044,13 +13217,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 213 /* AwaitExpression */: - case 206 /* TypeAssertionExpression */: + case 215 /* PrefixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: + case 211 /* DeleteExpression */: + case 212 /* TypeOfExpression */: + case 213 /* VoidExpression */: + case 214 /* AwaitExpression */: + case 207 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13059,9 +13232,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: return true; - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: return expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; default: @@ -13080,15 +13253,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: - case 209 /* ArrowFunction */: - case 216 /* BinaryExpression */: - case 220 /* SpreadElement */: - case 224 /* AsExpression */: - case 222 /* OmittedExpression */: - case 337 /* CommaListExpression */: - case 336 /* PartiallyEmittedExpression */: + case 218 /* ConditionalExpression */: + case 220 /* YieldExpression */: + case 210 /* ArrowFunction */: + case 217 /* BinaryExpression */: + case 221 /* SpreadElement */: + case 225 /* AsExpression */: + case 223 /* OmittedExpression */: + case 341 /* CommaListExpression */: + case 340 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13096,8 +13269,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 206 /* TypeAssertionExpression */ - || kind === 224 /* AsExpression */; + return kind === 207 /* TypeAssertionExpression */ + || kind === 225 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13108,13 +13281,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: return true; - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13143,7 +13316,7 @@ var ts; ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 238 /* ForInStatement */ || node.kind === 239 /* ForOfStatement */; + return node.kind === 239 /* ForInStatement */ || node.kind === 240 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13167,114 +13340,114 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */ + return kind === 258 /* ModuleBlock */ + || kind === 257 /* ModuleDeclaration */ || kind === 78 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 257 /* ModuleBlock */ - || kind === 256 /* ModuleDeclaration */; + return kind === 258 /* ModuleBlock */ + || kind === 257 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 78 /* Identifier */ - || kind === 256 /* ModuleDeclaration */; + || kind === 257 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 264 /* NamedImports */ - || kind === 263 /* NamespaceImport */; + return kind === 265 /* NamedImports */ + || kind === 264 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ || node.kind === 255 /* EnumDeclaration */; + return node.kind === 257 /* ModuleDeclaration */ || node.kind === 256 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 209 /* ArrowFunction */ - || kind === 198 /* BindingElement */ - || kind === 252 /* ClassDeclaration */ - || kind === 221 /* ClassExpression */ - || kind === 166 /* Constructor */ - || kind === 255 /* EnumDeclaration */ - || kind === 291 /* EnumMember */ - || kind === 270 /* ExportSpecifier */ - || kind === 251 /* FunctionDeclaration */ - || kind === 208 /* FunctionExpression */ - || kind === 167 /* GetAccessor */ - || kind === 262 /* ImportClause */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 265 /* ImportSpecifier */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 280 /* JsxAttribute */ - || kind === 165 /* MethodDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 256 /* ModuleDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 263 /* NamespaceImport */ - || kind === 269 /* NamespaceExport */ - || kind === 160 /* Parameter */ - || kind === 288 /* PropertyAssignment */ - || kind === 163 /* PropertyDeclaration */ - || kind === 162 /* PropertySignature */ - || kind === 168 /* SetAccessor */ - || kind === 289 /* ShorthandPropertyAssignment */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 159 /* TypeParameter */ - || kind === 249 /* VariableDeclaration */ - || kind === 331 /* JSDocTypedefTag */ - || kind === 324 /* JSDocCallbackTag */ - || kind === 333 /* JSDocPropertyTag */; + return kind === 210 /* ArrowFunction */ + || kind === 199 /* BindingElement */ + || kind === 253 /* ClassDeclaration */ + || kind === 222 /* ClassExpression */ + || kind === 167 /* Constructor */ + || kind === 256 /* EnumDeclaration */ + || kind === 292 /* EnumMember */ + || kind === 271 /* ExportSpecifier */ + || kind === 252 /* FunctionDeclaration */ + || kind === 209 /* FunctionExpression */ + || kind === 168 /* GetAccessor */ + || kind === 263 /* ImportClause */ + || kind === 261 /* ImportEqualsDeclaration */ + || kind === 266 /* ImportSpecifier */ + || kind === 254 /* InterfaceDeclaration */ + || kind === 281 /* JsxAttribute */ + || kind === 166 /* MethodDeclaration */ + || kind === 165 /* MethodSignature */ + || kind === 257 /* ModuleDeclaration */ + || kind === 260 /* NamespaceExportDeclaration */ + || kind === 264 /* NamespaceImport */ + || kind === 270 /* NamespaceExport */ + || kind === 161 /* Parameter */ + || kind === 289 /* PropertyAssignment */ + || kind === 164 /* PropertyDeclaration */ + || kind === 163 /* PropertySignature */ + || kind === 169 /* SetAccessor */ + || kind === 290 /* ShorthandPropertyAssignment */ + || kind === 255 /* TypeAliasDeclaration */ + || kind === 160 /* TypeParameter */ + || kind === 250 /* VariableDeclaration */ + || kind === 335 /* JSDocTypedefTag */ + || kind === 328 /* JSDocCallbackTag */ + || kind === 337 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 271 /* MissingDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 259 /* NamespaceExportDeclaration */; + return kind === 252 /* FunctionDeclaration */ + || kind === 272 /* MissingDeclaration */ + || kind === 253 /* ClassDeclaration */ + || kind === 254 /* InterfaceDeclaration */ + || kind === 255 /* TypeAliasDeclaration */ + || kind === 256 /* EnumDeclaration */ + || kind === 257 /* ModuleDeclaration */ + || kind === 262 /* ImportDeclaration */ + || kind === 261 /* ImportEqualsDeclaration */ + || kind === 268 /* ExportDeclaration */ + || kind === 267 /* ExportAssignment */ + || kind === 260 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 241 /* BreakStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 235 /* DoStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 231 /* EmptyStatement */ - || kind === 238 /* ForInStatement */ - || kind === 239 /* ForOfStatement */ - || kind === 237 /* ForStatement */ - || kind === 234 /* IfStatement */ - || kind === 245 /* LabeledStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 244 /* SwitchStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 247 /* TryStatement */ - || kind === 232 /* VariableStatement */ - || kind === 236 /* WhileStatement */ - || kind === 243 /* WithStatement */ - || kind === 335 /* NotEmittedStatement */ - || kind === 339 /* EndOfDeclarationMarker */ - || kind === 338 /* MergeDeclarationMarker */; + return kind === 242 /* BreakStatement */ + || kind === 241 /* ContinueStatement */ + || kind === 249 /* DebuggerStatement */ + || kind === 236 /* DoStatement */ + || kind === 234 /* ExpressionStatement */ + || kind === 232 /* EmptyStatement */ + || kind === 239 /* ForInStatement */ + || kind === 240 /* ForOfStatement */ + || kind === 238 /* ForStatement */ + || kind === 235 /* IfStatement */ + || kind === 246 /* LabeledStatement */ + || kind === 243 /* ReturnStatement */ + || kind === 245 /* SwitchStatement */ + || kind === 247 /* ThrowStatement */ + || kind === 248 /* TryStatement */ + || kind === 233 /* VariableStatement */ + || kind === 237 /* WhileStatement */ + || kind === 244 /* WithStatement */ + || kind === 339 /* NotEmittedStatement */ + || kind === 343 /* EndOfDeclarationMarker */ + || kind === 342 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 159 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 330 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 160 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 334 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13301,10 +13474,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 230 /* Block */) + if (node.kind !== 231 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 247 /* TryStatement */ || node.parent.kind === 287 /* CatchClause */) { + if (node.parent.kind === 248 /* TryStatement */ || node.parent.kind === 288 /* CatchClause */) { return false; } } @@ -13318,15 +13491,15 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 230 /* Block */; + || kind === 231 /* Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 272 /* ExternalModuleReference */ - || kind === 157 /* QualifiedName */ + return kind === 273 /* ExternalModuleReference */ + || kind === 158 /* QualifiedName */ || kind === 78 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -13336,70 +13509,76 @@ var ts; var kind = node.kind; return kind === 107 /* ThisKeyword */ || kind === 78 /* Identifier */ - || kind === 201 /* PropertyAccessExpression */; + || kind === 202 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 273 /* JsxElement */ - || kind === 283 /* JsxExpression */ - || kind === 274 /* JsxSelfClosingElement */ + return kind === 274 /* JsxElement */ + || kind === 284 /* JsxExpression */ + || kind === 275 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 277 /* JsxFragment */; + || kind === 278 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 280 /* JsxAttribute */ - || kind === 282 /* JsxSpreadAttribute */; + return kind === 281 /* JsxAttribute */ + || kind === 283 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 283 /* JsxExpression */; + || kind === 284 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 275 /* JsxOpeningElement */ - || kind === 274 /* JsxSelfClosingElement */; + return kind === 276 /* JsxOpeningElement */ + || kind === 275 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 284 /* CaseClause */ - || kind === 285 /* DefaultClause */; + return kind === 285 /* CaseClause */ + || kind === 286 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 301 /* FirstJSDocNode */ && node.kind <= 333 /* LastJSDocNode */; + return node.kind >= 302 /* FirstJSDocNode */ && node.kind <= 337 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 311 /* JSDocComment */ || node.kind === 310 /* JSDocNamepathType */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 312 /* JSDocComment */ + || node.kind === 311 /* JSDocNamepathType */ + || node.kind === 313 /* JSDocText */ + || node.kind === 316 /* JSDocLink */ + || isJSDocTag(node) + || ts.isJSDocTypeLiteral(node) + || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 314 /* FirstJSDocTagNode */ && node.kind <= 333 /* LastJSDocTagNode */; + return node.kind >= 317 /* FirstJSDocTagNode */ && node.kind <= 337 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 169 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 168 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -13425,13 +13604,13 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: + case 250 /* VariableDeclaration */: + case 161 /* Parameter */: + case 199 /* BindingElement */: + case 163 /* PropertySignature */: + case 164 /* PropertyDeclaration */: + case 289 /* PropertyAssignment */: + case 292 /* EnumMember */: return true; default: return false; @@ -13439,12 +13618,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 280 /* JsxAttribute */ || node.kind === 282 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 281 /* JsxAttribute */ || node.kind === 283 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 173 /* TypeReference */ || node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 174 /* TypeReference */ || node.kind === 224 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -13683,7 +13862,9 @@ var ts; } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { - return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; + return oldResolution.resolvedFileName === newResolution.resolvedFileName + && oldResolution.primary === newResolution.primary + && oldResolution.originalPath === newResolution.originalPath; } ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo; function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) { @@ -13725,7 +13906,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 297 /* SourceFile */) { + while (node && node.kind !== 298 /* SourceFile */) { node = node.parent; } return node; @@ -13733,11 +13914,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 231 /* Block */: + case 259 /* CaseBlock */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: return true; } return false; @@ -13933,10 +14114,12 @@ 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 === 334 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 338 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } - return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); + return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, + /*stopAfterLineBreak*/ false, + /*stopAtComments*/ false, isInJSDoc(node)); } ts.getTokenPosOfNode = getTokenPosOfNode; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -14055,9 +14238,11 @@ var ts; DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"], RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"] }, - esnext: { + es2021: { PromiseConstructor: ["any"], - String: ["replaceAll"], + String: ["replaceAll"] + }, + esnext: { NumberFormat: ["formatToParts"] } }; @@ -14150,7 +14335,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 249 /* VariableDeclaration */ && node.parent.kind === 287 /* CatchClause */; + return node.kind === 250 /* VariableDeclaration */ && node.parent.kind === 288 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -14182,11 +14367,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 === 256 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 257 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 297 /* SourceFile */ || - node.kind === 256 /* ModuleDeclaration */ || + return node.kind === 298 /* SourceFile */ || + node.kind === 257 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -14203,16 +14388,17 @@ 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 297 /* SourceFile */: + case 298 /* SourceFile */: return ts.isExternalModule(node.parent); - case 257 /* ModuleBlock */: + case 258 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; } ts.isModuleAugmentationExternal = isModuleAugmentationExternal; function getNonAugmentationDeclaration(symbol) { - return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); }); + var _a; + 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 isEffectiveExternalModule(node, compilerOptions) { @@ -14258,22 +14444,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 287 /* CatchClause */: - case 256 /* ModuleDeclaration */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 298 /* SourceFile */: + case 259 /* CaseBlock */: + case 288 /* CatchClause */: + case 257 /* ModuleDeclaration */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 167 /* Constructor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return true; - case 230 /* Block */: + case 231 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -14283,9 +14469,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 313 /* JSDocSignature */: + case 328 /* JSDocCallbackTag */: + case 335 /* JSDocTypedefTag */: + case 315 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -14295,25 +14481,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 165 /* MethodSignature */: + case 172 /* IndexSignature */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: + case 309 /* JSDocFunctionType */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 334 /* JSDocTemplateTag */: + case 252 /* FunctionDeclaration */: + case 166 /* MethodDeclaration */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -14323,8 +14509,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportDeclaration */: + case 261 /* ImportEqualsDeclaration */: return true; default: return false; @@ -14333,15 +14519,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: + case 262 /* ImportDeclaration */: + case 261 /* ImportEqualsDeclaration */: + case 233 /* VariableStatement */: + case 253 /* ClassDeclaration */: + case 252 /* FunctionDeclaration */: + case 257 /* ModuleDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 254 /* InterfaceDeclaration */: + case 256 /* EnumDeclaration */: return true; default: return false; @@ -14374,7 +14560,7 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 158 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 159 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { @@ -14386,7 +14572,7 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 159 /* 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"); @@ -14402,9 +14588,9 @@ var ts; case 79 /* PrivateIdentifier */: case 78 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } @@ -14490,7 +14676,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 230 /* Block */) { + if (node.body && node.body.kind === 231 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -14504,7 +14690,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 297 /* SourceFile */: + case 298 /* 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 @@ -14513,28 +14699,28 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 250 /* VariableDeclaration */: + case 199 /* BindingElement */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: + case 257 /* ModuleDeclaration */: + case 256 /* EnumDeclaration */: + case 292 /* EnumMember */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 255 /* TypeAliasDeclaration */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: errorNode = node.name; break; - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 285 /* CaseClause */: + case 286 /* 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); @@ -14586,11 +14772,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 105 /* SuperKeyword */; + return n.kind === 204 /* CallExpression */ && n.expression.kind === 105 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 203 /* CallExpression */ && n.expression.kind === 99 /* ImportKeyword */; + return n.kind === 204 /* CallExpression */ && n.expression.kind === 99 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { @@ -14604,7 +14790,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 233 /* ExpressionStatement */ + return node.kind === 234 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -14632,11 +14818,12 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 160 /* Parameter */ || - node.kind === 159 /* TypeParameter */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 209 /* ArrowFunction */ || - node.kind === 207 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 161 /* Parameter */ || + node.kind === 160 /* TypeParameter */ || + node.kind === 209 /* FunctionExpression */ || + node.kind === 210 /* ArrowFunction */ || + node.kind === 208 /* ParenthesizedExpression */ || + node.kind === 250 /* VariableDeclaration */) ? 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 '/**/' @@ -14652,7 +14839,7 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (172 /* FirstTypeNode */ <= node.kind && node.kind <= 195 /* LastTypeNode */) { + if (173 /* FirstTypeNode */ <= node.kind && node.kind <= 196 /* LastTypeNode */) { return true; } switch (node.kind) { @@ -14668,32 +14855,32 @@ var ts; case 141 /* NeverKeyword */: return true; case 113 /* VoidKeyword */: - return node.parent.kind !== 212 /* VoidExpression */; - case 223 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 213 /* VoidExpression */; + case 224 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 159 /* TypeParameter */: - return node.parent.kind === 190 /* MappedType */ || node.parent.kind === 185 /* InferType */; + case 160 /* TypeParameter */: + return node.parent.kind === 191 /* MappedType */ || node.parent.kind === 186 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 78 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 158 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 202 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */ || node.kind === 201 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 78 /* Identifier */ || node.kind === 158 /* QualifiedName */ || node.kind === 202 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: + case 158 /* QualifiedName */: + case 202 /* PropertyAccessExpression */: case 107 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 176 /* TypeQuery */) { + if (parent.kind === 177 /* TypeQuery */) { return false; } - if (parent.kind === 195 /* ImportType */) { + if (parent.kind === 196 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -14702,40 +14889,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 (172 /* FirstTypeNode */ <= parent.kind && parent.kind <= 195 /* LastTypeNode */) { + if (173 /* FirstTypeNode */ <= parent.kind && parent.kind <= 196 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 159 /* TypeParameter */: + case 160 /* TypeParameter */: return node === parent.constraint; - case 330 /* JSDocTemplateTag */: + case 334 /* JSDocTemplateTag */: return node === parent.constraint; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 161 /* Parameter */: + case 250 /* VariableDeclaration */: return node === parent.type; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 167 /* Constructor */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return node === parent.type; - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 172 /* IndexSignature */: return node === parent.type; - case 206 /* TypeAssertionExpression */: + case 207 /* TypeAssertionExpression */: return node === parent.type; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -14760,23 +14947,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: return visitor(node); - case 258 /* CaseBlock */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 259 /* CaseBlock */: + case 231 /* Block */: + case 235 /* IfStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 244 /* WithStatement */: + case 245 /* SwitchStatement */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: + case 246 /* LabeledStatement */: + case 248 /* TryStatement */: + case 288 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -14786,23 +14973,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 219 /* YieldExpression */: + case 220 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 256 /* EnumDeclaration */: + case 254 /* InterfaceDeclaration */: + case 257 /* ModuleDeclaration */: + case 255 /* 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 159 /* 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); @@ -14825,10 +15012,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 178 /* ArrayType */) { + if (node && node.kind === 179 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 173 /* TypeReference */) { + else if (node && node.kind === 174 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -14838,12 +15025,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 177 /* TypeLiteral */: + case 254 /* InterfaceDeclaration */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 178 /* TypeLiteral */: return node.members; - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return node.properties; } } @@ -14851,14 +15038,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 198 /* BindingElement */: - case 291 /* EnumMember */: - case 160 /* Parameter */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 249 /* VariableDeclaration */: + case 199 /* BindingElement */: + case 292 /* EnumMember */: + case 161 /* Parameter */: + case 289 /* PropertyAssignment */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 290 /* ShorthandPropertyAssignment */: + case 250 /* VariableDeclaration */: return true; } } @@ -14870,8 +15057,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ - && node.parent.parent.kind === 232 /* VariableStatement */; + return node.parent.kind === 251 /* VariableDeclarationList */ + && node.parent.parent.kind === 233 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -14882,13 +15069,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: return true; } return false; @@ -14899,7 +15086,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 245 /* LabeledStatement */) { + if (node.statement.kind !== 246 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -14907,17 +15094,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 230 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 231 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 165 /* MethodDeclaration */ && node.parent.kind === 200 /* ObjectLiteralExpression */; + return node && node.kind === 166 /* MethodDeclaration */ && node.parent.kind === 201 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 165 /* MethodDeclaration */ && - (node.parent.kind === 200 /* ObjectLiteralExpression */ || - node.parent.kind === 221 /* ClassExpression */); + return node.kind === 166 /* MethodDeclaration */ && + (node.parent.kind === 201 /* ObjectLiteralExpression */ || + node.parent.kind === 222 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -14930,7 +15117,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 288 /* PropertyAssignment */) { + if (property.kind === 289 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -14979,14 +15166,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 297 /* SourceFile */); + ts.Debug.assert(node.kind !== 298 /* 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 158 /* ComputedPropertyName */: + case 159 /* 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 @@ -15001,9 +15188,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 161 /* Decorator */: + case 162 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 161 /* 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; @@ -15014,26 +15201,26 @@ var ts; node = node.parent; } break; - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 256 /* ModuleDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 255 /* EnumDeclaration */: - case 297 /* SourceFile */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 257 /* ModuleDeclaration */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 172 /* IndexSignature */: + case 256 /* EnumDeclaration */: + case 298 /* SourceFile */: return node; } } @@ -15052,9 +15239,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 167 /* Constructor */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: return container; } } @@ -15076,27 +15263,27 @@ var ts; return node; } switch (node.kind) { - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: node = node.parent; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return node; - case 161 /* Decorator */: + case 162 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 160 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 161 /* 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; @@ -15112,14 +15299,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 208 /* FunctionExpression */ || func.kind === 209 /* ArrowFunction */) { + if (func.kind === 209 /* FunctionExpression */ || func.kind === 210 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 207 /* ParenthesizedExpression */) { + while (parent.kind === 208 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 203 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 204 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -15135,7 +15322,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) + return (kind === 202 /* PropertyAccessExpression */ || kind === 203 /* ElementAccessExpression */) && node.expression.kind === 105 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -15144,7 +15331,7 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 201 /* PropertyAccessExpression */ || kind === 202 /* ElementAccessExpression */) + return (kind === 202 /* PropertyAccessExpression */ || kind === 203 /* ElementAccessExpression */) && node.expression.kind === 107 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; @@ -15153,17 +15340,25 @@ var ts; return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 107 /* ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; + function isThisInitializedObjectBindingExpression(node) { + return !!node + && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) + && ts.isBinaryExpression(node.parent.parent) + && node.parent.parent.operatorToken.kind === 62 /* EqualsToken */ + && node.parent.parent.right.kind === 107 /* ThisKeyword */; + } + ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 174 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. case 78 /* Identifier */: - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: return node; } return undefined; @@ -15171,10 +15366,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return node.tag; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxOpeningElement */: + case 275 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -15187,25 +15382,25 @@ var ts; return false; } switch (node.kind) { - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: // classes are valid targets return true; - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 252 /* ClassDeclaration */; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + return parent.kind === 253 /* ClassDeclaration */; + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 166 /* 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 === 252 /* ClassDeclaration */; - case 160 /* Parameter */: + && parent.kind === 253 /* ClassDeclaration */; + case 161 /* 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 === 166 /* Constructor */ - || parent.kind === 165 /* MethodDeclaration */ - || parent.kind === 168 /* SetAccessor */) - && grandparent.kind === 252 /* ClassDeclaration */; + && (parent.kind === 167 /* Constructor */ + || parent.kind === 166 /* MethodDeclaration */ + || parent.kind === 169 /* SetAccessor */) + && grandparent.kind === 253 /* ClassDeclaration */; } return false; } @@ -15221,10 +15416,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 169 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -15233,9 +15428,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 275 /* JsxOpeningElement */ || - parent.kind === 274 /* JsxSelfClosingElement */ || - parent.kind === 276 /* JsxClosingElement */) { + if (parent.kind === 276 /* JsxOpeningElement */ || + parent.kind === 275 /* JsxSelfClosingElement */ || + parent.kind === 277 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -15248,44 +15443,44 @@ var ts; case 109 /* TrueKeyword */: case 94 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 224 /* AsExpression */: - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 211 /* TypeOfExpression */: - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: - case 216 /* BinaryExpression */: - case 217 /* ConditionalExpression */: - case 220 /* SpreadElement */: - case 218 /* TemplateExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: - case 219 /* YieldExpression */: - case 213 /* AwaitExpression */: - case 226 /* MetaProperty */: + case 200 /* ArrayLiteralExpression */: + case 201 /* ObjectLiteralExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: + case 206 /* TaggedTemplateExpression */: + case 225 /* AsExpression */: + case 207 /* TypeAssertionExpression */: + case 226 /* NonNullExpression */: + case 208 /* ParenthesizedExpression */: + case 209 /* FunctionExpression */: + case 222 /* ClassExpression */: + case 210 /* ArrowFunction */: + case 213 /* VoidExpression */: + case 211 /* DeleteExpression */: + case 212 /* TypeOfExpression */: + case 215 /* PrefixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: + case 217 /* BinaryExpression */: + case 218 /* ConditionalExpression */: + case 221 /* SpreadElement */: + case 219 /* TemplateExpression */: + case 223 /* OmittedExpression */: + case 274 /* JsxElement */: + case 275 /* JsxSelfClosingElement */: + case 278 /* JsxFragment */: + case 220 /* YieldExpression */: + case 214 /* AwaitExpression */: + case 227 /* MetaProperty */: return true; - case 157 /* QualifiedName */: - while (node.parent.kind === 157 /* QualifiedName */) { + case 158 /* QualifiedName */: + while (node.parent.kind === 158 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 177 /* TypeQuery */ || isJSXTagName(node); case 78 /* Identifier */: - if (node.parent.kind === 176 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 177 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through @@ -15303,49 +15498,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 198 /* BindingElement */: + case 250 /* VariableDeclaration */: + case 161 /* Parameter */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 292 /* EnumMember */: + case 289 /* PropertyAssignment */: + case 199 /* BindingElement */: return parent.initializer === node; - case 233 /* ExpressionStatement */: - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 242 /* ReturnStatement */: - case 243 /* WithStatement */: - case 244 /* SwitchStatement */: - case 284 /* CaseClause */: - case 246 /* ThrowStatement */: + case 234 /* ExpressionStatement */: + case 235 /* IfStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: + case 243 /* ReturnStatement */: + case 244 /* WithStatement */: + case 245 /* SwitchStatement */: + case 285 /* CaseClause */: + case 247 /* ThrowStatement */: return parent.expression === node; - case 237 /* ForStatement */: + case 238 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 251 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 250 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 251 /* VariableDeclarationList */) || forInStatement.expression === node; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 207 /* TypeAssertionExpression */: + case 225 /* AsExpression */: return node === parent.expression; - case 228 /* TemplateSpan */: + case 229 /* TemplateSpan */: return node === parent.expression; - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: return node === parent.expression; - case 161 /* Decorator */: - case 283 /* JsxExpression */: - case 282 /* JsxSpreadAttribute */: - case 290 /* SpreadAssignment */: + case 162 /* Decorator */: + case 284 /* JsxExpression */: + case 283 /* JsxSpreadAttribute */: + case 291 /* SpreadAssignment */: return true; - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -15353,14 +15548,18 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 157 /* QualifiedName */ || node.kind === 78 /* Identifier */) { + while (node.kind === 158 /* QualifiedName */ || node.kind === 78 /* Identifier */) { node = node.parent; } - return node.kind === 176 /* TypeQuery */; + return node.kind === 177 /* TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; + function isNamespaceReexportDeclaration(node) { + return ts.isNamespaceExport(node) && !!node.parent.moduleSpecifier; + } + ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 272 /* ExternalModuleReference */; + return node.kind === 261 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 273 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -15369,12 +15568,11 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function getExternalModuleRequireArgument(node) { - return isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) - && getLeftmostAccessExpression(node.initializer).arguments[0]; + return isRequireVariableDeclaration(node) && getLeftmostAccessExpression(node.initializer).arguments[0]; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 272 /* ExternalModuleReference */; + return node.kind === 261 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 273 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -15410,7 +15608,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 203 /* CallExpression */) { + if (callExpression.kind !== 204 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -15424,18 +15622,21 @@ var ts; return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; - function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) { - if (node.kind === 198 /* BindingElement */) { + /** + * Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`). + * This function does not test if the node is in a JavaScript file or not. + */ + function isRequireVariableDeclaration(node) { + if (node.kind === 199 /* BindingElement */) { node = node.parent.parent; } - return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), requireStringLiteralLikeArgument); + return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), /*requireStringLiteralLikeArgument*/ true); } ts.isRequireVariableDeclaration = isRequireVariableDeclaration; - function isRequireVariableStatement(node, requireStringLiteralLikeArgument) { - if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; } + function isRequireVariableStatement(node) { return ts.isVariableStatement(node) && node.declarationList.declarations.length > 0 - && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); }); + && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl); }); } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { @@ -15507,11 +15708,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 208 /* FunctionExpression */ || e.kind === 209 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 209 /* FunctionExpression */ || e.kind === 210 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 208 /* FunctionExpression */ || - initializer.kind === 221 /* ClassExpression */ || - initializer.kind === 209 /* ArrowFunction */) { + if (initializer.kind === 209 /* FunctionExpression */ || + initializer.kind === 222 /* ClassExpression */ || + initializer.kind === 210 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -15632,8 +15833,7 @@ var ts; ts.isLiteralLikeAccess = isLiteralLikeAccess; /** x[0] OR x['a'] OR x[Symbol.y] */ function isLiteralLikeElementAccess(node) { - return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || - isWellKnownSymbolSyntactically(node.argumentExpression)); + return ts.isElementAccessExpression(node) && isStringOrNumericLiteralLike(node.argumentExpression); } ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ @@ -15713,9 +15913,6 @@ var ts; return ts.escapeLeadingUnderscores(name.text); } } - if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); - } return undefined; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; @@ -15765,7 +15962,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 233 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 234 /* ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -15786,23 +15983,37 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 251 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 252 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; + function tryGetModuleSpecifierFromDeclaration(node) { + var _a, _b, _c; + switch (node.kind) { + case 250 /* VariableDeclaration */: + return node.initializer.arguments[0].text; + case 262 /* ImportDeclaration */: + return (_a = ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text; + case 261 /* 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); + } + } + ts.tryGetModuleSpecifierFromDeclaration = tryGetModuleSpecifierFromDeclaration; function importFromModuleSpecifier(node) { return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent); } ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 262 /* ImportDeclaration */: + case 268 /* ExportDeclaration */: return node.parent; - case 272 /* ExternalModuleReference */: + case 273 /* ExternalModuleReference */: return node.parent.parent; - case 203 /* CallExpression */: + case 204 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 191 /* LiteralType */: + case 192 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -15812,16 +16023,16 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 262 /* ImportDeclaration */: + case 268 /* ExportDeclaration */: return node.moduleSpecifier; - case 260 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 272 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 195 /* ImportType */: + case 261 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 273 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 196 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 203 /* CallExpression */: + case 204 /* CallExpression */: return node.arguments[0]; - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); @@ -15830,11 +16041,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return node; - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -15842,7 +16053,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 261 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 262 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -15863,13 +16074,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 160 /* Parameter */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 289 /* ShorthandPropertyAssignment */: - case 288 /* PropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 161 /* Parameter */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 290 /* ShorthandPropertyAssignment */: + case 289 /* PropertyAssignment */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -15883,7 +16094,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 331 /* JSDocTypedefTag */ || node.kind === 324 /* JSDocCallbackTag */ || node.kind === 325 /* JSDocEnumTag */; + return node.kind === 335 /* JSDocTypedefTag */ || node.kind === 328 /* JSDocCallbackTag */ || node.kind === 329 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -15908,12 +16119,12 @@ var ts; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: return node.initializer; - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: return node.initializer; } } @@ -15925,7 +16136,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 256 /* ModuleDeclaration */ + node.body.kind === 257 /* ModuleDeclaration */ ? node.body : undefined; } @@ -15940,11 +16151,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 160 /* Parameter */) { + if (node.kind === 161 /* Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 159 /* TypeParameter */) { + if (node.kind === 160 /* TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -15955,10 +16166,11 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 288 /* PropertyAssignment */ || - parent.kind === 266 /* ExportAssignment */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 233 /* ExpressionStatement */ && node.kind === 201 /* PropertyAccessExpression */ || + if (parent.kind === 289 /* PropertyAssignment */ || + parent.kind === 267 /* ExportAssignment */ || + parent.kind === 164 /* PropertyDeclaration */ || + parent.kind === 234 /* ExpressionStatement */ && node.kind === 202 /* PropertyAccessExpression */ || + parent.kind === 243 /* ReturnStatement */ || getNestedModuleDeclaration(parent) || ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; @@ -16045,7 +16257,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 === 309 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 310 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; function hasTypeArguments(node) { @@ -16062,31 +16274,34 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 62 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 207 /* ParenthesizedExpression */: - case 199 /* ArrayLiteralExpression */: - case 220 /* SpreadElement */: - case 225 /* NonNullExpression */: + case 208 /* ParenthesizedExpression */: + case 200 /* ArrayLiteralExpression */: + case 221 /* SpreadElement */: + case 226 /* NonNullExpression */: node = parent; break; - case 289 /* ShorthandPropertyAssignment */: + case 291 /* SpreadAssignment */: + node = parent.parent; + break; + case 290 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -16113,22 +16328,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 230 /* Block */: - case 232 /* VariableStatement */: - case 243 /* WithStatement */: - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 245 /* LabeledStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 287 /* CatchClause */: + case 231 /* Block */: + case 233 /* VariableStatement */: + case 244 /* WithStatement */: + case 235 /* IfStatement */: + case 245 /* SwitchStatement */: + case 259 /* CaseBlock */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: + case 246 /* LabeledStatement */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: + case 248 /* TryStatement */: + case 288 /* CatchClause */: return true; } return false; @@ -16145,11 +16360,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 186 /* ParenthesizedType */); + return walkUp(node, 187 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 207 /* ParenthesizedExpression */); + return walkUp(node, 208 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -16159,7 +16374,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 186 /* ParenthesizedType */) { + while (node && node.kind === 187 /* ParenthesizedType */) { child = node; node = node.parent; } @@ -16171,18 +16386,18 @@ var ts; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 207 /* ParenthesizedExpression */) { + while (node.kind === 208 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 201 /* PropertyAccessExpression */ && node.kind !== 202 /* ElementAccessExpression */) { + if (node.kind !== 202 /* PropertyAccessExpression */ && node.kind !== 203 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 210 /* DeleteExpression */; + return node && node.kind === 211 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -16235,7 +16450,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 158 /* ComputedPropertyName */ && + node.parent.kind === 159 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -16243,26 +16458,26 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 291 /* EnumMember */: - case 288 /* PropertyAssignment */: - case 201 /* PropertyAccessExpression */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 292 /* EnumMember */: + case 289 /* PropertyAssignment */: + case 202 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 198 /* BindingElement */: - case 265 /* ImportSpecifier */: + case 199 /* BindingElement */: + case 266 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 270 /* ExportSpecifier */: - case 280 /* JsxAttribute */: + case 271 /* ExportSpecifier */: + case 281 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -16282,33 +16497,33 @@ var ts; // {} // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 259 /* NamespaceExportDeclaration */ || - node.kind === 262 /* ImportClause */ && !!node.name || - node.kind === 263 /* NamespaceImport */ || - node.kind === 269 /* NamespaceExport */ || - node.kind === 265 /* ImportSpecifier */ || - node.kind === 270 /* ExportSpecifier */ || - node.kind === 266 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 261 /* ImportEqualsDeclaration */ || + node.kind === 260 /* NamespaceExportDeclaration */ || + node.kind === 263 /* ImportClause */ && !!node.name || + node.kind === 264 /* NamespaceImport */ || + node.kind === 270 /* NamespaceExport */ || + node.kind === 266 /* ImportSpecifier */ || + node.kind === 271 /* ExportSpecifier */ || + node.kind === 267 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || - node.kind === 289 /* ShorthandPropertyAssignment */ || - node.kind === 288 /* PropertyAssignment */ && isAliasableExpression(node.initializer); + node.kind === 290 /* ShorthandPropertyAssignment */ || + node.kind === 289 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 263 /* NamespaceImport */: - case 270 /* ExportSpecifier */: - case 266 /* ExportAssignment */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportClause */: + case 266 /* ImportSpecifier */: + case 264 /* NamespaceImport */: + case 271 /* ExportSpecifier */: + case 267 /* ExportAssignment */: + case 261 /* ImportEqualsDeclaration */: return node.parent; - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 157 /* QualifiedName */); + } while (node.parent.kind === 158 /* QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -16327,7 +16542,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 288 /* PropertyAssignment */ ? node.initializer : + return node.kind === 290 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 289 /* PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -16393,11 +16608,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 80 /* FirstKeyword */ <= token && token <= 156 /* LastKeyword */; + return 80 /* FirstKeyword */ <= token && token <= 157 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 125 /* FirstContextualKeyword */ <= token && token <= 156 /* LastContextualKeyword */; + return 125 /* FirstContextualKeyword */ <= token && token <= 157 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -16441,14 +16656,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 166 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: if (hasSyntacticModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -16462,10 +16677,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 166 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasSyntacticModifier(node, 256 /* Async */); @@ -16488,9 +16703,6 @@ var ts; * 3. The computed name is *not* expressed as a NumericLiteral. * 4. The computed name is *not* expressed as a PlusToken or MinusToken * immediately followed by a NumericLiteral. - * 5. The computed name is *not* expressed as `Symbol.`, where `` - * is a property of the Symbol constructor that denotes a built-in - * Symbol. */ function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); @@ -16498,24 +16710,14 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 158 /* ComputedPropertyName */ || name.kind === 202 /* ElementAccessExpression */)) { + if (!(name.kind === 159 /* ComputedPropertyName */ || name.kind === 203 /* ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; return !isStringOrNumericLiteralLike(expr) && - !isSignedNumericLiteral(expr) && - !isWellKnownSymbolSyntactically(expr); + !isSignedNumericLiteral(expr); } ts.isDynamicName = isDynamicName; - /** - * Checks if the expression is of the form: - * Symbol.name - * where Symbol is literally the word "Symbol", and name is any identifierName - */ - function isWellKnownSymbolSyntactically(node) { - return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression); - } - ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { case 78 /* Identifier */: @@ -16524,12 +16726,9 @@ var ts; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: var nameExpression = name.expression; - if (isWellKnownSymbolSyntactically(nameExpression)) { - return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - else if (isStringOrNumericLiteralLike(nameExpression)) { + if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { @@ -16557,21 +16756,17 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text; + return ts.isMemberName(node) ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return ts.isMemberName(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; - function getPropertyNameForKnownSymbolName(symbolName) { - return "__@" + symbolName; - } - ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; } @@ -16593,11 +16788,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 160 /* Parameter */; + return root.kind === 161 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 198 /* BindingElement */) { + while (node.kind === 199 /* BindingElement */) { node = node.parent.parent; } return node; @@ -16605,15 +16800,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 166 /* Constructor */ - || kind === 208 /* FunctionExpression */ - || kind === 251 /* FunctionDeclaration */ - || kind === 209 /* ArrowFunction */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 256 /* ModuleDeclaration */ - || kind === 297 /* SourceFile */; + return kind === 167 /* Constructor */ + || kind === 209 /* FunctionExpression */ + || kind === 252 /* FunctionDeclaration */ + || kind === 210 /* ArrowFunction */ + || kind === 166 /* MethodDeclaration */ + || kind === 168 /* GetAccessor */ + || kind === 169 /* SetAccessor */ + || kind === 257 /* ModuleDeclaration */ + || kind === 298 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -16632,23 +16827,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 205 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 204 /* NewExpression */: + case 205 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: - case 217 /* ConditionalExpression */: - case 219 /* YieldExpression */: + case 215 /* PrefixUnaryExpression */: + case 212 /* TypeOfExpression */: + case 213 /* VoidExpression */: + case 211 /* DeleteExpression */: + case 214 /* AwaitExpression */: + case 218 /* ConditionalExpression */: + case 220 /* YieldExpression */: return 1 /* Right */; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: switch (operator) { case 42 /* AsteriskAsteriskToken */: case 62 /* EqualsToken */: @@ -16675,15 +16870,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 204 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 205 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 216 /* BinaryExpression */) { + if (expression.kind === 217 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 214 /* PrefixUnaryExpression */ || expression.kind === 215 /* PostfixUnaryExpression */) { + else if (expression.kind === 215 /* PrefixUnaryExpression */ || expression.kind === 216 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -16862,15 +17057,15 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 337 /* CommaListExpression */: + case 341 /* CommaListExpression */: return 0 /* Comma */; - case 220 /* SpreadElement */: + case 221 /* SpreadElement */: return 1 /* Spread */; - case 219 /* YieldExpression */: + case 220 /* YieldExpression */: return 2 /* Yield */; - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: return 4 /* Conditional */; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0 /* Comma */; @@ -16895,25 +17090,26 @@ var ts; return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 206 /* TypeAssertionExpression */: - case 225 /* NonNullExpression */: - case 214 /* PrefixUnaryExpression */: - case 211 /* TypeOfExpression */: - case 212 /* VoidExpression */: - case 210 /* DeleteExpression */: - case 213 /* AwaitExpression */: + case 207 /* TypeAssertionExpression */: + case 226 /* NonNullExpression */: + case 215 /* PrefixUnaryExpression */: + case 212 /* TypeOfExpression */: + case 213 /* VoidExpression */: + case 211 /* DeleteExpression */: + case 214 /* AwaitExpression */: return 16 /* Unary */; - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: return 17 /* Update */; - case 203 /* CallExpression */: + case 204 /* CallExpression */: return 18 /* LeftHandSide */; - case 204 /* NewExpression */: + case 205 /* NewExpression */: return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 205 /* TaggedTemplateExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 206 /* TaggedTemplateExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: + case 227 /* MetaProperty */: return 19 /* Member */; - case 224 /* AsExpression */: + case 225 /* AsExpression */: return 11 /* Relational */; case 107 /* ThisKeyword */: case 105 /* SuperKeyword */: @@ -16924,19 +17120,19 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 200 /* ArrayLiteralExpression */: + case 201 /* ObjectLiteralExpression */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 222 /* ClassExpression */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 207 /* ParenthesizedExpression */: - case 222 /* OmittedExpression */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 219 /* TemplateExpression */: + case 208 /* ParenthesizedExpression */: + case 223 /* OmittedExpression */: + case 274 /* JsxElement */: + case 275 /* JsxSelfClosingElement */: + case 278 /* JsxFragment */: return 20 /* Primary */; default: return -1 /* Invalid */; @@ -16992,7 +17188,7 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: return !!i.expression; case 11 /* JsxText */: return !i.containsOnlyTriviaWhiteSpaces; @@ -17483,8 +17679,8 @@ var ts; return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) && !sourceFile.isDeclarationFile && !host.isSourceFileFromExternalLibrary(sourceFile) && - !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && - (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName)); + (forceDtsEmit || (!(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) && + !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName))); } ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted; function getSourceFilePathInNewDir(fileName, host, newDirPath) { @@ -17579,10 +17775,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 168 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 168 /* SetAccessor */) { + else if (accessor.kind === 169 /* SetAccessor */) { setAccessor = accessor; } else { @@ -17602,10 +17798,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 167 /* GetAccessor */ && !getAccessor) { + if (member.kind === 168 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 168 /* SetAccessor */ && !setAccessor) { + if (member.kind === 169 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -17654,7 +17850,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 === 311 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 312 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -17877,6 +18073,18 @@ var ts; return hasSyntacticModifier(node, 32 /* Static */); } ts.hasStaticModifier = hasStaticModifier; + function hasOverrideModifier(node) { + return hasEffectiveModifier(node, 16384 /* Override */); + } + ts.hasOverrideModifier = hasOverrideModifier; + function hasAbstractModifier(node) { + return hasSyntacticModifier(node, 128 /* Abstract */); + } + ts.hasAbstractModifier = hasAbstractModifier; + function hasAmbientModifier(node) { + return hasSyntacticModifier(node, 2 /* Ambient */); + } + ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { return hasEffectiveModifier(node, 64 /* Readonly */); } @@ -17890,7 +18098,7 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 156 /* LastToken */) { + if (node.kind >= 0 /* FirstToken */ && node.kind <= 157 /* LastToken */) { return 0 /* None */; } if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { @@ -17935,6 +18143,8 @@ var ts; flags |= 16 /* Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) flags |= 64 /* Readonly */; + if (ts.getJSDocOverrideTagNoCache(node)) + flags |= 16384 /* Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) flags |= 8192 /* Deprecated */; @@ -17987,10 +18197,15 @@ var ts; case 87 /* DefaultKeyword */: return 512 /* Default */; case 129 /* AsyncKeyword */: return 256 /* Async */; case 142 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 156 /* OverrideKeyword */: return 16384 /* Override */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; + function createModifiers(modifierFlags) { + return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; + } + ts.createModifiers = createModifiers; function isLogicalOperator(token) { return token === 56 /* BarBarToken */ || token === 55 /* AmpersandAmpersandToken */ @@ -18033,11 +18248,15 @@ var ts; && ts.isLeftHandSideExpression(node.left); } ts.isAssignmentExpression = isAssignmentExpression; + function isLeftHandSideOfAssignment(node) { + return isAssignmentExpression(node.parent) && node.parent.left === node; + } + ts.isLeftHandSideOfAssignment = isLeftHandSideOfAssignment; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 200 /* ObjectLiteralExpression */ - || kind === 199 /* ArrayLiteralExpression */; + return kind === 201 /* ObjectLiteralExpression */ + || kind === 200 /* ArrayLiteralExpression */; } return false; } @@ -18054,12 +18273,12 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: do { node = node.left; } while (node.kind !== 78 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 78 /* Identifier */); @@ -18068,9 +18287,12 @@ var ts; } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 78 /* Identifier */ || node.kind === 107 /* ThisKeyword */ || node.kind === 105 /* SuperKeyword */ || - node.kind === 201 /* PropertyAccessExpression */ && isDottedName(node.expression) || - node.kind === 207 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 78 /* Identifier */ + || node.kind === 107 /* ThisKeyword */ + || node.kind === 105 /* SuperKeyword */ + || node.kind === 227 /* MetaProperty */ + || node.kind === 202 /* PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 208 /* ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -18101,22 +18323,22 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 157 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 158 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 202 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 200 /* ObjectLiteralExpression */ && + return expression.kind === 201 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 199 /* ArrayLiteralExpression */ && + return expression.kind === 200 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - if (!isExportDefaultSymbol(symbol)) + if (!isExportDefaultSymbol(symbol) || !symbol.declarations) return undefined; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; @@ -18443,8 +18665,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 256 /* EnumDeclaration */: + case 257 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -18471,9 +18693,11 @@ var ts; return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; - function getDeclarationModifierFlagsFromSymbol(s) { + function getDeclarationModifierFlagsFromSymbol(s, isWrite) { + if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var flags = ts.getCombinedModifierFlags(s.valueDeclaration); + var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 169 /* SetAccessor */; })) || s.valueDeclaration; + var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; } if (getCheckFlags(s) & 6 /* Synthetic */) { @@ -18521,35 +18745,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return accessKind(parent); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 288 /* PropertyAssignment */: { + case 289 /* 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 289 /* ShorthandPropertyAssignment */: + case 290 /* 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 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && skipParenthesesUp(parent.parent).kind === 233 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 234 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -18637,7 +18861,8 @@ var ts; } ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol; function getClassLikeDeclarationOfSymbol(symbol) { - return ts.find(symbol.declarations, ts.isClassLike); + var _a; + return (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { @@ -18680,7 +18905,6 @@ var ts; ts.getLastChild = getLastChild; function addToSeen(seen, key, value) { if (value === void 0) { value = true; } - key = String(key); if (seen.has(key)) { return false; } @@ -18693,7 +18917,7 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) + return (kind >= 173 /* FirstTypeNode */ && kind <= 196 /* LastTypeNode */) || kind === 128 /* AnyKeyword */ || kind === 152 /* UnknownKeyword */ || kind === 144 /* NumberKeyword */ @@ -18705,25 +18929,25 @@ var ts; || kind === 113 /* VoidKeyword */ || kind === 150 /* UndefinedKeyword */ || kind === 141 /* NeverKeyword */ - || kind === 223 /* ExpressionWithTypeArguments */ - || kind === 303 /* JSDocAllType */ - || kind === 304 /* JSDocUnknownType */ - || kind === 305 /* JSDocNullableType */ - || kind === 306 /* JSDocNonNullableType */ - || kind === 307 /* JSDocOptionalType */ - || kind === 308 /* JSDocFunctionType */ - || kind === 309 /* JSDocVariadicType */; + || kind === 224 /* ExpressionWithTypeArguments */ + || kind === 304 /* JSDocAllType */ + || kind === 305 /* JSDocUnknownType */ + || kind === 306 /* JSDocNullableType */ + || kind === 307 /* JSDocNonNullableType */ + || kind === 308 /* JSDocOptionalType */ + || kind === 309 /* JSDocFunctionType */ + || kind === 310 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */ || node.kind === 202 /* ElementAccessExpression */; + return node.kind === 202 /* PropertyAccessExpression */ || node.kind === 203 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 201 /* PropertyAccessExpression */) { + if (node.kind === 202 /* PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 202 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 203 /* ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; @@ -18738,7 +18962,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 264 /* NamedImports */ || node.kind === 268 /* NamedExports */; + return node.kind === 265 /* NamedImports */ || node.kind === 269 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -18751,28 +18975,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: node = node.operand; continue; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: node = node.left; continue; - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: node = node.condition; continue; - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: node = node.tag; continue; - case 203 /* CallExpression */: + case 204 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 224 /* AsExpression */: - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: - case 225 /* NonNullExpression */: - case 336 /* PartiallyEmittedExpression */: + case 225 /* AsExpression */: + case 203 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 226 /* NonNullExpression */: + case 340 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -19151,6 +19375,10 @@ var ts; return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; + function getUseDefineForClassFields(compilerOptions) { + return compilerOptions.useDefineForClassFields === undefined ? compilerOptions.target === 99 /* ESNext */ : compilerOptions.useDefineForClassFields; + } + ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { return oldOptions !== newOptions && ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); @@ -19172,7 +19400,7 @@ var ts; ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); - var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[0] : jsxImportSourcePragmas; + var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; return compilerOptions.jsx === 4 /* ReactJSX */ || compilerOptions.jsx === 5 /* ReactJSXDev */ || compilerOptions.jsxImportSource || @@ -19222,19 +19450,33 @@ var ts; } (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real); } - } + }, + setSymlinkedDirectoryFromSymlinkedFile: function (symlink, real) { + this.setSymlinkedFile(ts.toPath(symlink, cwd, getCanonicalFileName), real); + var _a = guessDirectorySymlink(real, symlink, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _a[0], commonOriginal = _a[1]; + if (commonResolved && commonOriginal) { + this.setSymlinkedDirectory(commonOriginal, { + real: commonResolved, + realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName), + }); + } + }, }; } ts.createSymlinkCache = createSymlinkCache; function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { var cache = createSymlinkCache(cwd, getCanonicalFileName); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + var symlinks = ts.flatMap(files, function (sf) { + var pairs = sf.resolvedModules && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedModules.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) ? [res.resolvedFileName, res.originalPath] : undefined; + })); + return ts.concatenate(pairs, sf.resolvedTypeReferenceDirectiveNames && ts.arrayFrom(ts.mapDefinedIterator(sf.resolvedTypeReferenceDirectiveNames.values(), function (res) { + return (res === null || res === void 0 ? void 0 : res.originalPath) && res.resolvedFileName ? [res.resolvedFileName, res.originalPath] : undefined; }))); - })); + }); for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + cache.setSymlinkedFile(ts.toPath(originalPath, cwd, getCanonicalFileName), resolvedPath); var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _b[0], commonOriginal = _b[1]; if (commonResolved && commonOriginal) { cache.setSymlinkedDirectory(commonOriginal, { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) }); @@ -19933,21 +20175,21 @@ var ts; } ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite; function typeOnlyDeclarationIsExport(typeOnlyDeclaration) { - return typeOnlyDeclaration.kind === 270 /* ExportSpecifier */; + return typeOnlyDeclaration.kind === 271 /* ExportSpecifier */; } ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport; function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 78 /* Identifier */ || node.kind === 201 /* PropertyAccessExpression */) { + while (node.kind === 78 /* Identifier */ || node.kind === 202 /* PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 159 /* ComputedPropertyName */) { return false; } if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 253 /* InterfaceDeclaration */ || containerKind === 177 /* TypeLiteral */; + return containerKind === 254 /* InterfaceDeclaration */ || containerKind === 178 /* TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { @@ -19955,16 +20197,16 @@ var ts; return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 286 /* HeritageClause */: + case 287 /* HeritageClause */: return true; - case 201 /* PropertyAccessExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 202 /* PropertyAccessExpression */: + case 224 /* ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 253 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 254 /* InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -20121,6 +20363,72 @@ var ts; return ts.some(ts.ignoredPaths, function (p) { return ts.stringContains(path, p); }); } ts.containsIgnoredPath = containsIgnoredPath; + function getContainingNodeArray(node) { + if (!node.parent) + return undefined; + switch (node.kind) { + case 160 /* TypeParameter */: + var parent_1 = node.parent; + return parent_1.kind === 186 /* InferType */ ? undefined : parent_1.typeParameters; + case 161 /* Parameter */: + return node.parent.parameters; + case 195 /* TemplateLiteralTypeSpan */: + return node.parent.templateSpans; + case 229 /* TemplateSpan */: + return node.parent.templateSpans; + case 162 /* Decorator */: + return node.parent.decorators; + case 287 /* HeritageClause */: + return node.parent.heritageClauses; + } + var parent = node.parent; + if (ts.isJSDocTag(node)) { + return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; + } + switch (parent.kind) { + case 178 /* TypeLiteral */: + case 254 /* InterfaceDeclaration */: + return ts.isTypeElement(node) ? parent.members : undefined; + case 183 /* UnionType */: + case 184 /* IntersectionType */: + return parent.types; + case 180 /* TupleType */: + case 200 /* ArrayLiteralExpression */: + case 341 /* CommaListExpression */: + case 265 /* NamedImports */: + case 269 /* NamedExports */: + return parent.elements; + case 201 /* ObjectLiteralExpression */: + case 282 /* JsxAttributes */: + return parent.properties; + case 204 /* CallExpression */: + case 205 /* NewExpression */: + return ts.isTypeNode(node) ? parent.typeArguments : + parent.expression === node ? undefined : + parent.arguments; + case 274 /* JsxElement */: + case 278 /* JsxFragment */: + return ts.isJsxChild(node) ? parent.children : undefined; + case 276 /* JsxOpeningElement */: + case 275 /* JsxSelfClosingElement */: + return ts.isTypeNode(node) ? parent.typeArguments : undefined; + case 231 /* Block */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: + case 258 /* ModuleBlock */: + return parent.statements; + case 259 /* CaseBlock */: + return parent.clauses; + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + return ts.isClassElement(node) ? parent.members : undefined; + case 256 /* EnumDeclaration */: + return ts.isEnumMember(node) ? parent.members : undefined; + case 298 /* SourceFile */: + return parent.statements; + } + } + ts.getContainingNodeArray = getContainingNodeArray; })(ts || (ts = {})); /* @internal */ var ts; @@ -20165,7 +20473,11 @@ var ts; var ts; (function (ts) { function createParenthesizerRules(factory) { + var binaryLeftOperandParenthesizerCache; + var binaryRightOperandParenthesizerCache; return { + getParenthesizeLeftSideOfBinaryForOperator: getParenthesizeLeftSideOfBinaryForOperator, + getParenthesizeRightSideOfBinaryForOperator: getParenthesizeRightSideOfBinaryForOperator, parenthesizeLeftSideOfBinary: parenthesizeLeftSideOfBinary, parenthesizeRightSideOfBinary: parenthesizeRightSideOfBinary, parenthesizeExpressionOfComputedPropertyName: parenthesizeExpressionOfComputedPropertyName, @@ -20186,6 +20498,24 @@ var ts; parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType, parenthesizeTypeArguments: parenthesizeTypeArguments, }; + function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) { + binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryLeftOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeLeftSideOfBinary(operatorKind, node); }; + binaryLeftOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } + function getParenthesizeRightSideOfBinaryForOperator(operatorKind) { + binaryRightOperandParenthesizerCache || (binaryRightOperandParenthesizerCache = new ts.Map()); + var parenthesizerRule = binaryRightOperandParenthesizerCache.get(operatorKind); + if (!parenthesizerRule) { + parenthesizerRule = function (node) { return parenthesizeRightSideOfBinary(operatorKind, /*leftSide*/ undefined, node); }; + binaryRightOperandParenthesizerCache.set(operatorKind, parenthesizerRule); + } + return parenthesizerRule; + } /** * Determines whether the operand to a BinaryExpression needs to be parenthesized. * @@ -20212,10 +20542,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(216 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(216 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(217 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(217 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 209 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 210 /* 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; @@ -20227,7 +20557,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 219 /* YieldExpression */) { + && operand.kind === 220 /* YieldExpression */) { return false; } return true; @@ -20315,7 +20645,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 217 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -20341,7 +20671,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 === 207 /* ParenthesizedExpression */) { + if (skipped.kind === 208 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -20358,7 +20688,7 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(217 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(218 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { @@ -20391,8 +20721,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: + case 222 /* ClassExpression */: + case 209 /* FunctionExpression */: needsParens = true; } } @@ -20405,9 +20735,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 203 /* CallExpression */: + case 204 /* CallExpression */: return factory.createParenthesizedExpression(expression); - case 204 /* NewExpression */: + case 205 /* NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -20427,7 +20757,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 204 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 205 /* NewExpression */ || emittedExpression.arguments)) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -20449,7 +20779,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(216 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(217 /* BinaryExpression */, 27 /* CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -20458,44 +20788,44 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 208 /* FunctionExpression */ || kind === 209 /* ArrowFunction */) { + if (kind === 209 /* FunctionExpression */ || kind === 210 /* 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 === 200 /* ObjectLiteralExpression */ || leftmostExpressionKind === 208 /* FunctionExpression */) { + if (leftmostExpressionKind === 201 /* ObjectLiteralExpression */ || leftmostExpressionKind === 209 /* 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 === 200 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 201 /* ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } return body; } function parenthesizeMemberOfConditionalType(member) { - return member.kind === 184 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; + return member.kind === 185 /* ConditionalType */ ? factory.createParenthesizedType(member) : member; } function parenthesizeMemberOfElementType(member) { switch (member.kind) { - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 183 /* UnionType */: + case 184 /* IntersectionType */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfConditionalType(member); } function parenthesizeElementTypeOfArrayType(member) { switch (member.kind) { - case 176 /* TypeQuery */: - case 188 /* TypeOperator */: - case 185 /* InferType */: + case 177 /* TypeQuery */: + case 189 /* TypeOperator */: + case 186 /* InferType */: return factory.createParenthesizedType(member); } return parenthesizeMemberOfElementType(member); @@ -20514,6 +20844,8 @@ var ts; } ts.createParenthesizerRules = createParenthesizerRules; ts.nullParenthesizerRules = { + getParenthesizeLeftSideOfBinaryForOperator: function (_) { return ts.identity; }, + getParenthesizeRightSideOfBinaryForOperator: function (_) { return ts.identity; }, parenthesizeLeftSideOfBinary: function (_binaryOperator, leftSide) { return leftSide; }, parenthesizeRightSideOfBinary: function (_binaryOperator, _leftSide, rightSide) { return rightSide; }, parenthesizeExpressionOfComputedPropertyName: ts.identity, @@ -20599,11 +20931,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 198 /* ArrayBindingPattern */: + case 200 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 196 /* ObjectBindingPattern */: - case 200 /* ObjectLiteralExpression */: + case 197 /* ObjectBindingPattern */: + case 201 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -20944,18 +21276,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(303 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(304 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(306 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(306 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(305 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(305 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(307 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(307 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(309 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(309 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(304 /* JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(305 /* JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(307 /* JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(307 /* JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(306 /* JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(306 /* JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(308 /* JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(308 /* JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(310 /* JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(310 /* JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(311 /* JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(311 /* JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -20982,31 +21314,37 @@ var ts; updateJSDocSeeTag: updateJSDocSeeTag, createJSDocNameReference: createJSDocNameReference, updateJSDocNameReference: updateJSDocNameReference, + createJSDocLink: createJSDocLink, + updateJSDocLink: updateJSDocLink, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(329 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(329 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(327 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(327 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(328 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(328 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(325 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(325 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(317 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(317 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(319 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(319 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(320 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(320 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(321 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(321 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(322 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(322 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(323 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(323 /* JSDocReadonlyTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(318 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(318 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(333 /* JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(333 /* JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(331 /* JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(331 /* JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(332 /* JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(332 /* JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(329 /* JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(329 /* JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(320 /* JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(320 /* JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(322 /* JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(322 /* JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(323 /* JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(323 /* JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(324 /* JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(324 /* JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(325 /* JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(325 /* JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(326 /* JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(326 /* JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(327 /* JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(327 /* JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(321 /* JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(321 /* JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, + createJSDocText: createJSDocText, + updateJSDocText: updateJSDocText, createJSDocComment: createJSDocComment, updateJSDocComment: updateJSDocComment, createJsxElement: createJsxElement, @@ -21190,11 +21528,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 164 /* PropertyDeclaration */: + case 289 /* PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -21235,7 +21573,7 @@ var ts; function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~8388608 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~16777216 /* ContainsPossibleTopLevelAwait */; if (!body) node.transformFlags |= 1 /* ContainsTypeScript */; return node; @@ -21288,7 +21626,7 @@ var ts; var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21307,7 +21645,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21363,7 +21701,7 @@ var ts; node.typeArguments = createNodeArray(typeArguments); } if (node.originalKeywordKind === 130 /* AwaitKeyword */) { - node.transformFlags |= 8388608 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= 16777216 /* ContainsPossibleTopLevelAwait */; } return node; } @@ -21386,8 +21724,11 @@ var ts; } /** Create a unique temporary variable for use in a loop. */ // @api - function createLoopVariable() { - return createBaseGeneratedIdentifier("", 2 /* Loop */); + function createLoopVariable(reservedInNestedScopes) { + var flags = 2 /* Loop */; + if (reservedInNestedScopes) + flags |= 8 /* ReservedInNestedScopes */; + return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api @@ -21412,7 +21753,7 @@ var ts; ts.Debug.fail("First character of private identifier must be #: " + text); var node = baseFactory.createBasePrivateIdentifierNode(79 /* PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 4194304 /* ContainsClassFields */; + node.transformFlags |= 8388608 /* ContainsClassFields */; return node; } // @@ -21422,7 +21763,7 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 156 /* LastToken */, "Invalid token"); + ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 157 /* LastToken */, "Invalid token"); ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); ts.Debug.assert(token !== 78 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); @@ -21432,8 +21773,8 @@ var ts; case 129 /* AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; break; case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: @@ -21447,6 +21788,7 @@ var ts; case 155 /* BigIntKeyword */: case 141 /* NeverKeyword */: case 145 /* ObjectKeyword */: + case 156 /* OverrideKeyword */: case 147 /* StringKeyword */: case 131 /* BooleanKeyword */: case 148 /* SymbolKeyword */: @@ -21457,11 +21799,11 @@ var ts; break; case 123 /* StaticKeyword */: case 105 /* SuperKeyword */: - transformFlags = 256 /* ContainsES2015 */; + transformFlags = 512 /* ContainsES2015 */; break; case 107 /* ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 4096 /* ContainsLexicalThis */; + transformFlags = 8192 /* ContainsLexicalThis */; break; } if (transformFlags) { @@ -21529,6 +21871,9 @@ var ts; if (flags & 32 /* Static */) { result.push(createModifier(123 /* StaticKeyword */)); } + if (flags & 16384 /* Override */) { + result.push(createModifier(156 /* OverrideKeyword */)); + } if (flags & 64 /* Readonly */) { result.push(createModifier(142 /* ReadonlyKeyword */)); } @@ -21542,7 +21887,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(157 /* QualifiedName */); + var node = createBaseNode(158 /* QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -21559,12 +21904,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(158 /* ComputedPropertyName */); + var node = createBaseNode(159 /* ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 32768 /* ContainsComputedPropertyName */; + 512 /* ContainsES2015 */ | + 65536 /* ContainsComputedPropertyName */; return node; } // @api @@ -21578,7 +21923,7 @@ var ts; // // @api function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createBaseNamedDeclaration(159 /* TypeParameter */, + var node = createBaseNamedDeclaration(160 /* TypeParameter */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.constraint = constraint; @@ -21596,7 +21941,7 @@ var ts; } // @api function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(160 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(161 /* Parameter */, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { @@ -21608,10 +21953,10 @@ var ts; propagateChildFlags(node.questionToken); if (questionToken) node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 92 /* ParameterPropertyModifier */) - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; } return node; } @@ -21629,12 +21974,12 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(161 /* Decorator */); + var node = createBaseNode(162 /* Decorator */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | 1 /* ContainsTypeScript */ | - 2048 /* ContainsTypeScriptClassSyntax */; + 4096 /* ContainsTypeScriptClassSyntax */; return node; } // @api @@ -21648,7 +21993,7 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(162 /* PropertySignature */, + var node = createBaseNamedDeclaration(163 /* PropertySignature */, /*decorators*/ undefined, modifiers, name); node.type = type; node.questionToken = questionToken; @@ -21666,15 +22011,15 @@ var ts; } // @api function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(163 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(164 /* PropertyDeclaration */, decorators, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 4194304 /* ContainsClassFields */; + 8388608 /* ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 2048 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 4096 /* ContainsTypeScriptClassSyntax */; } if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags |= 1 /* ContainsTypeScript */; @@ -21695,7 +22040,7 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(164 /* MethodSignature */, + var node = createBaseSignatureDeclaration(165 /* MethodSignature */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21714,26 +22059,26 @@ var ts; } // @api function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(165 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(166 /* MethodDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (questionToken) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -21753,11 +22098,11 @@ var ts; } // @api function createConstructorDeclaration(decorators, modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(166 /* Constructor */, decorators, modifiers, + var node = createBaseFunctionLikeDeclaration(167 /* Constructor */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -21771,7 +22116,7 @@ var ts; } // @api function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) { - return createBaseFunctionLikeDeclaration(167 /* GetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(168 /* GetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); } // @api @@ -21787,7 +22132,7 @@ var ts; } // @api function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) { - return createBaseFunctionLikeDeclaration(168 /* SetAccessor */, decorators, modifiers, name, + return createBaseFunctionLikeDeclaration(169 /* SetAccessor */, decorators, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -21803,7 +22148,7 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(169 /* CallSignature */, + var node = createBaseSignatureDeclaration(170 /* CallSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21820,7 +22165,7 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(170 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(171 /* ConstructSignature */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21837,7 +22182,7 @@ var ts; } // @api function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(171 /* IndexSignature */, decorators, modifiers, + var node = createBaseSignatureDeclaration(172 /* IndexSignature */, decorators, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21854,7 +22199,7 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(194 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(195 /* TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; @@ -21876,7 +22221,7 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(172 /* TypePredicate */); + var node = createBaseNode(173 /* TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; @@ -21893,7 +22238,7 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(173 /* TypeReference */); + var node = createBaseNode(174 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21908,7 +22253,7 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* FunctionType */, + var node = createBaseSignatureDeclaration(175 /* FunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); @@ -21934,7 +22279,7 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructorType */, + var node = createBaseSignatureDeclaration(176 /* ConstructorType */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -21968,7 +22313,7 @@ var ts; } // @api function createTypeQueryNode(exprName) { - var node = createBaseNode(176 /* TypeQuery */); + var node = createBaseNode(177 /* TypeQuery */); node.exprName = exprName; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21981,7 +22326,7 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(177 /* TypeLiteral */); + var node = createBaseNode(178 /* TypeLiteral */); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -21994,7 +22339,7 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(178 /* ArrayType */); + var node = createBaseNode(179 /* ArrayType */); node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22007,7 +22352,7 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(179 /* TupleType */); + var node = createBaseNode(180 /* TupleType */); node.elements = createNodeArray(elements); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22020,7 +22365,7 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(192 /* NamedTupleMember */); + var node = createBaseNode(193 /* NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; @@ -22039,7 +22384,7 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(180 /* OptionalType */); + var node = createBaseNode(181 /* OptionalType */); node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22052,7 +22397,7 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(181 /* RestType */); + var node = createBaseNode(182 /* RestType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22076,7 +22421,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(182 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(183 /* UnionType */, types); } // @api function updateUnionTypeNode(node, types) { @@ -22084,7 +22429,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(183 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(184 /* IntersectionType */, types); } // @api function updateIntersectionTypeNode(node, types) { @@ -22092,7 +22437,7 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(184 /* ConditionalType */); + var node = createBaseNode(185 /* ConditionalType */); node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType); node.trueType = trueType; @@ -22111,7 +22456,7 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(185 /* InferType */); + var node = createBaseNode(186 /* InferType */); node.typeParameter = typeParameter; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22124,7 +22469,7 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(193 /* TemplateLiteralType */); + var node = createBaseNode(194 /* TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22140,7 +22485,7 @@ var ts; // @api function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(195 /* ImportType */); + var node = createBaseNode(196 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); @@ -22160,7 +22505,7 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(186 /* ParenthesizedType */); + var node = createBaseNode(187 /* ParenthesizedType */); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22173,13 +22518,13 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(187 /* ThisType */); + var node = createBaseNode(188 /* ThisType */); node.transformFlags = 1 /* ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(188 /* TypeOperator */); + var node = createBaseNode(189 /* TypeOperator */); node.operator = operator; node.type = parenthesizerRules().parenthesizeMemberOfElementType(type); node.transformFlags = 1 /* ContainsTypeScript */; @@ -22193,7 +22538,7 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(189 /* IndexedAccessType */); + var node = createBaseNode(190 /* IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType); node.indexType = indexType; node.transformFlags = 1 /* ContainsTypeScript */; @@ -22208,7 +22553,7 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) { - var node = createBaseNode(190 /* MappedType */); + var node = createBaseNode(191 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; @@ -22229,7 +22574,7 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(191 /* LiteralType */); + var node = createBaseNode(192 /* LiteralType */); node.literal = literal; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -22245,16 +22590,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(196 /* ObjectBindingPattern */); + var node = createBaseNode(197 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { node.transformFlags |= - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; } return node; } @@ -22266,12 +22611,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(197 /* ArrayBindingPattern */); + var node = createBaseNode(198 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 256 /* ContainsES2015 */ | - 131072 /* ContainsBindingPattern */; + 512 /* ContainsES2015 */ | + 262144 /* ContainsBindingPattern */; return node; } // @api @@ -22282,21 +22627,21 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(198 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(199 /* BindingElement */, /*decorators*/ undefined, - /*modifiers*/ undefined, name, initializer); + /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 8192 /* ContainsRestOrSpread */; + node.transformFlags |= 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22318,7 +22663,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(199 /* ArrayLiteralExpression */); + var node = createBaseExpression(200 /* ArrayLiteralExpression */); node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements)); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.elements); @@ -22332,7 +22677,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(200 /* ObjectLiteralExpression */); + var node = createBaseExpression(201 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -22346,7 +22691,7 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(202 /* PropertyAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.name = asName(name); node.transformFlags = @@ -22358,8 +22703,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22375,13 +22720,13 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(201 /* PropertyAccessExpression */); + var node = createBaseExpression(202 /* PropertyAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 8 /* ContainsES2020 */ | + 16 /* ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? @@ -22402,7 +22747,7 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(203 /* ElementAccessExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.argumentExpression = asExpression(index); node.transformFlags |= @@ -22412,8 +22757,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */; } return node; } @@ -22429,7 +22774,7 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(202 /* ElementAccessExpression */); + var node = createBaseExpression(203 /* ElementAccessExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22438,7 +22783,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; return node; } // @api @@ -22454,7 +22799,7 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(204 /* CallExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -22466,10 +22811,10 @@ var ts; node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 2097152 /* ContainsDynamicImport */; + node.transformFlags |= 4194304 /* ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22486,7 +22831,7 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(203 /* CallExpression */); + var node = createBaseExpression(204 /* CallExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.questionDotToken = questionDotToken; @@ -22497,12 +22842,12 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 4096 /* ContainsLexicalThis */; + node.transformFlags |= 8192 /* ContainsLexicalThis */; } return node; } @@ -22518,7 +22863,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(204 /* NewExpression */); + var node = createBaseExpression(205 /* NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -22526,7 +22871,7 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 8 /* ContainsES2020 */; + 16 /* ContainsES2020 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } @@ -22542,7 +22887,7 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(205 /* TaggedTemplateExpression */); + var node = createBaseExpression(206 /* TaggedTemplateExpression */); node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); node.typeArguments = asNodeArray(typeArguments); node.template = template; @@ -22550,12 +22895,12 @@ var ts; propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (node.typeArguments) { node.transformFlags |= 1 /* ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22569,7 +22914,7 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(206 /* TypeAssertionExpression */); + var node = createBaseExpression(207 /* TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= @@ -22587,7 +22932,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(207 /* ParenthesizedExpression */); + var node = createBaseExpression(208 /* ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -22600,7 +22945,7 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(208 /* FunctionExpression */, + var node = createBaseFunctionLikeDeclaration(209 /* FunctionExpression */, /*decorators*/ undefined, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); @@ -22609,14 +22954,14 @@ var ts; } if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } return node; } @@ -22634,15 +22979,15 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(209 /* ArrowFunction */, + var node = createBaseFunctionLikeDeclaration(210 /* ArrowFunction */, /*decorators*/ undefined, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } return node; } @@ -22659,7 +23004,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(210 /* DeleteExpression */); + var node = createBaseExpression(211 /* DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22672,7 +23017,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(211 /* TypeOfExpression */); + var node = createBaseExpression(212 /* TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22685,7 +23030,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(212 /* VoidExpression */); + var node = createBaseExpression(213 /* VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -22698,13 +23043,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(213 /* AwaitExpression */); + var node = createBaseExpression(214 /* AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 64 /* ContainsES2017 */ | - 32 /* ContainsES2018 */ | - 524288 /* ContainsAwait */; + 128 /* ContainsES2017 */ | + 64 /* ContainsES2018 */ | + 1048576 /* ContainsAwait */; return node; } // @api @@ -22715,7 +23060,7 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(214 /* PrefixUnaryExpression */); + var node = createBaseExpression(215 /* PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -22729,7 +23074,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(215 /* PostfixUnaryExpression */); + var node = createBaseExpression(216 /* PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags = propagateChildFlags(node.operand); @@ -22743,7 +23088,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(216 /* BinaryExpression */); + var node = createBaseExpression(217 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -22754,45 +23099,45 @@ var ts; propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 8 /* ContainsES2020 */; + node.transformFlags |= 16 /* ContainsES2020 */; } else if (operatorKind === 62 /* EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 1024 /* ContainsDestructuringAssignment */ | + 512 /* ContainsES2015 */ | + 2048 /* ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 66 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 128 /* ContainsES2016 */; + node.transformFlags |= 256 /* ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 8 /* ContainsES2021 */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) - return 16384 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 32 /* ContainsES2018 */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) + return 32768 /* ContainsObjectRestOrSpread */; + if (node.transformFlags & 64 /* ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { - return 16384 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { + return 32768 /* ContainsObjectRestOrSpread */; } - if (target.transformFlags & 32 /* ContainsES2018 */) { + if (target.transformFlags & 64 /* ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -22812,7 +23157,7 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(217 /* ConditionalExpression */); + var node = createBaseExpression(218 /* ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); @@ -22838,13 +23183,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(218 /* TemplateExpression */); + var node = createBaseExpression(219 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22883,9 +23228,9 @@ var ts; node.text = text; node.rawText = rawText; node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } return node; } @@ -22908,15 +23253,15 @@ var ts; // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(219 /* YieldExpression */); + var node = createBaseExpression(220 /* YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 256 /* ContainsES2015 */ | - 32 /* ContainsES2018 */ | - 262144 /* ContainsYield */; + 512 /* ContainsES2015 */ | + 64 /* ContainsES2018 */ | + 524288 /* ContainsYield */; return node; } // @api @@ -22928,12 +23273,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(220 /* SpreadElement */); + var node = createBaseExpression(221 /* SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2015 */ | - 8192 /* ContainsRestOrSpread */; + 512 /* ContainsES2015 */ | + 16384 /* ContainsRestOrSpread */; return node; } // @api @@ -22944,8 +23289,8 @@ var ts; } // @api function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(221 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(222 /* ClassExpression */, decorators, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @api @@ -22961,17 +23306,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(222 /* OmittedExpression */); + return createBaseExpression(223 /* OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(223 /* ExpressionWithTypeArguments */); + var node = createBaseNode(224 /* ExpressionWithTypeArguments */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -22983,7 +23328,7 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(224 /* AsExpression */); + var node = createBaseExpression(225 /* AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= @@ -23001,7 +23346,7 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(226 /* NonNullExpression */); node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= propagateChildFlags(node.expression) | @@ -23019,7 +23364,7 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(225 /* NonNullExpression */); + var node = createBaseExpression(226 /* NonNullExpression */); node.flags |= 32 /* OptionalChain */; node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); node.transformFlags |= @@ -23036,13 +23381,13 @@ var ts; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(226 /* MetaProperty */); + var node = createBaseExpression(227 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { case 102 /* NewKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; break; case 99 /* ImportKeyword */: node.transformFlags |= 4 /* ContainsESNext */; @@ -23063,13 +23408,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(228 /* TemplateSpan */); + var node = createBaseNode(229 /* TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } // @api @@ -23081,8 +23426,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(229 /* SemicolonClassElement */); - node.transformFlags |= 256 /* ContainsES2015 */; + var node = createBaseNode(230 /* SemicolonClassElement */); + node.transformFlags |= 512 /* ContainsES2015 */; return node; } // @@ -23090,7 +23435,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(230 /* Block */); + var node = createBaseNode(231 /* Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -23104,7 +23449,7 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(232 /* VariableStatement */, /*decorators*/ undefined, modifiers); + var node = createBaseDeclaration(233 /* VariableStatement */, /*decorators*/ undefined, modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildFlags(node.declarationList); @@ -23122,11 +23467,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(231 /* EmptyStatement */); + return createBaseNode(232 /* EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(233 /* ExpressionStatement */); + var node = createBaseNode(234 /* ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23139,7 +23484,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(234 /* IfStatement */); + var node = createBaseNode(235 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -23159,7 +23504,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(235 /* DoStatement */); + var node = createBaseNode(236 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -23176,7 +23521,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(236 /* WhileStatement */); + var node = createBaseNode(237 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23193,7 +23538,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(237 /* ForStatement */); + var node = createBaseNode(238 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -23216,7 +23561,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(238 /* ForInStatement */); + var node = createBaseNode(239 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -23236,7 +23581,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(239 /* ForOfStatement */); + var node = createBaseNode(240 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -23246,9 +23591,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; return node; } // @api @@ -23262,11 +23607,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(240 /* ContinueStatement */); + var node = createBaseNode(241 /* ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23277,11 +23622,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(241 /* BreakStatement */); + var node = createBaseNode(242 /* BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23292,13 +23637,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(242 /* ReturnStatement */); + var node = createBaseNode(243 /* ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 64 /* ContainsES2018 */ | + 2097152 /* ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -23309,7 +23654,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(243 /* WithStatement */); + var node = createBaseNode(244 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23326,7 +23671,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(244 /* SwitchStatement */); + var node = createBaseNode(245 /* SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -23343,7 +23688,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(245 /* LabeledStatement */); + var node = createBaseNode(246 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -23360,7 +23705,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(246 /* ThrowStatement */); + var node = createBaseNode(247 /* ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -23373,7 +23718,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(247 /* TryStatement */); + var node = createBaseNode(248 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -23393,11 +23738,11 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(248 /* DebuggerStatement */); + return createBaseNode(249 /* DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(249 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(250 /* VariableDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; @@ -23419,16 +23764,16 @@ var ts; // @api function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(250 /* VariableDeclarationList */); + var node = createBaseNode(251 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (flags & 3 /* BlockScoped */) { node.transformFlags |= - 256 /* ContainsES2015 */ | - 65536 /* ContainsBlockScopedBinding */; + 512 /* ContainsES2015 */ | + 131072 /* ContainsBlockScopedBinding */; } return node; } @@ -23440,7 +23785,7 @@ var ts; } // @api function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(251 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(252 /* FunctionDeclaration */, decorators, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; @@ -23448,17 +23793,17 @@ var ts; else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 1048576 /* ContainsHoistedDeclarationOrCompletion */; + 2097152 /* ContainsHoistedDeclarationOrCompletion */; if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { if (node.asteriskToken) { - node.transformFlags |= 32 /* ContainsES2018 */; + node.transformFlags |= 64 /* ContainsES2018 */; } else { - node.transformFlags |= 64 /* ContainsES2017 */; + node.transformFlags |= 128 /* ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 512 /* ContainsGenerator */; + node.transformFlags |= 1024 /* ContainsGenerator */; } } return node; @@ -23478,13 +23823,13 @@ var ts; } // @api function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(252 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); + var node = createBaseClassLikeDeclaration(253 /* ClassDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses, members); if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { node.transformFlags = 1 /* ContainsTypeScript */; } else { - node.transformFlags |= 256 /* ContainsES2015 */; - if (node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 512 /* ContainsES2015 */; + if (node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */) { node.transformFlags |= 1 /* ContainsTypeScript */; } } @@ -23503,7 +23848,7 @@ var ts; } // @api function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(253 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(254 /* InterfaceDeclaration */, decorators, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23521,7 +23866,7 @@ var ts; } // @api function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(254 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(255 /* TypeAliasDeclaration */, decorators, modifiers, name, typeParameters); node.type = type; node.transformFlags = 1 /* ContainsTypeScript */; return node; @@ -23538,12 +23883,12 @@ var ts; } // @api function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createBaseNamedDeclaration(255 /* EnumDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(256 /* EnumDeclaration */, decorators, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` return node; } // @api @@ -23558,7 +23903,7 @@ var ts; // @api function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(256 /* ModuleDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(257 /* ModuleDeclaration */, decorators, modifiers); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.name = name; node.body = body; @@ -23571,7 +23916,7 @@ var ts; propagateChildFlags(node.body) | 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. return node; } // @api @@ -23585,7 +23930,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(257 /* ModuleBlock */); + var node = createBaseNode(258 /* ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -23598,7 +23943,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(258 /* CaseBlock */); + var node = createBaseNode(259 /* CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -23611,7 +23956,7 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(259 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(260 /* NamespaceExportDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.transformFlags = 1 /* ContainsTypeScript */; @@ -23625,13 +23970,13 @@ var ts; } // @api function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(260 /* ImportEqualsDeclaration */, decorators, modifiers, name); + var node = createBaseNamedDeclaration(261 /* ImportEqualsDeclaration */, decorators, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context return node; } // @api @@ -23646,13 +23991,13 @@ var ts; } // @api function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createBaseDeclaration(261 /* ImportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(262 /* ImportDeclaration */, decorators, modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23666,7 +24011,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(262 /* ImportClause */); + var node = createBaseNode(263 /* ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -23676,7 +24021,7 @@ var ts; if (isTypeOnly) { node.transformFlags |= 1 /* ContainsTypeScript */; } - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23689,10 +24034,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(263 /* NamespaceImport */); + var node = createBaseNode(264 /* NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23703,12 +24048,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(269 /* NamespaceExport */); + var node = createBaseNode(270 /* NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | 4 /* ContainsESNext */; - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23719,10 +24064,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(264 /* NamedImports */); + var node = createBaseNode(265 /* NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23733,13 +24078,13 @@ var ts; } // @api function createImportSpecifier(propertyName, name) { - var node = createBaseNode(265 /* ImportSpecifier */); + var node = createBaseNode(266 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23751,13 +24096,13 @@ var ts; } // @api function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(266 /* ExportAssignment */, decorators, modifiers); + var node = createBaseDeclaration(267 /* ExportAssignment */, decorators, modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals ? parenthesizerRules().parenthesizeRightSideOfBinary(62 /* EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23770,14 +24115,14 @@ var ts; } // @api function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) { - var node = createBaseDeclaration(267 /* ExportDeclaration */, decorators, modifiers); + var node = createBaseDeclaration(268 /* ExportDeclaration */, decorators, modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; node.transformFlags |= propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23792,10 +24137,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(268 /* NamedExports */); + var node = createBaseNode(269 /* NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23806,13 +24151,13 @@ var ts; } // @api function createExportSpecifier(propertyName, name) { - var node = createBaseNode(270 /* ExportSpecifier */); + var node = createBaseNode(271 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23824,7 +24169,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(271 /* MissingDeclaration */, + var node = createBaseDeclaration(272 /* MissingDeclaration */, /*decorators*/ undefined, /*modifiers*/ undefined); return node; @@ -23834,10 +24179,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(272 /* ExternalModuleReference */); + var node = createBaseNode(273 /* ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~8388608 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~16777216 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -23879,7 +24224,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(308 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(309 /* JSDocFunctionType */, /*decorators*/ undefined, /*modifiers*/ undefined, /*name*/ undefined, @@ -23896,7 +24241,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(312 /* JSDocTypeLiteral */); + var node = createBaseNode(314 /* JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -23910,7 +24255,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(301 /* JSDocTypeExpression */); + var node = createBaseNode(302 /* JSDocTypeExpression */); node.type = type; return node; } @@ -23922,7 +24267,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(313 /* JSDocSignature */); + var node = createBaseNode(315 /* JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -23951,7 +24296,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(330 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(334 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -23968,7 +24313,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(331 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(335 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -23986,7 +24331,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(326 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(330 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -24007,7 +24352,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(333 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(337 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -24028,7 +24373,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(324 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(328 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -24046,7 +24391,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(315 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(318 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -24061,13 +24406,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(316 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(319 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(332 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(336 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -24081,7 +24426,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(302 /* JSDocNameReference */); + var node = createBaseNode(303 /* JSDocNameReference */); node.name = name; return node; } @@ -24092,6 +24437,19 @@ var ts; : node; } // @api + function createJSDocLink(name, text) { + var node = createBaseNode(316 /* JSDocLink */); + node.name = name; + node.text = text; + return node; + } + // @api + function updateJSDocLink(node, name, text) { + return node.name !== name + ? update(createJSDocLink(name, text), node) + : node; + } + // @api function updateJSDocImplementsTag(node, tagName, className, comment) { if (tagName === void 0) { tagName = getDefaultTagName(node); } return node.tagName !== tagName @@ -24152,7 +24510,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(314 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(317 /* JSDocTag */, tagName, comment); return node; } // @api @@ -24163,8 +24521,20 @@ var ts; : node; } // @api + function createJSDocText(text) { + var node = createBaseNode(313 /* JSDocText */); + node.text = text; + return node; + } + // @api + function updateJSDocText(node, text) { + return node.text !== text + ? update(createJSDocText(text), node) + : node; + } + // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(311 /* JSDocComment */); + var node = createBaseNode(312 /* JSDocComment */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -24181,7 +24551,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(273 /* JsxElement */); + var node = createBaseNode(274 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -24202,7 +24572,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(274 /* JsxSelfClosingElement */); + var node = createBaseNode(275 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -24226,7 +24596,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(275 /* JsxOpeningElement */); + var node = createBaseNode(276 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -24250,7 +24620,7 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(276 /* JsxClosingElement */); + var node = createBaseNode(277 /* JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | @@ -24265,7 +24635,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(277 /* JsxFragment */); + var node = createBaseNode(278 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -24301,19 +24671,19 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(278 /* JsxOpeningFragment */); + var node = createBaseNode(279 /* JsxOpeningFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(279 /* JsxClosingFragment */); + var node = createBaseNode(280 /* JsxClosingFragment */); node.transformFlags |= 2 /* ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(280 /* JsxAttribute */); + var node = createBaseNode(281 /* JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= @@ -24331,7 +24701,7 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(281 /* JsxAttributes */); + var node = createBaseNode(282 /* JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | @@ -24346,7 +24716,7 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(282 /* JsxSpreadAttribute */); + var node = createBaseNode(283 /* JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | @@ -24361,7 +24731,7 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(283 /* JsxExpression */); + var node = createBaseNode(284 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= @@ -24381,7 +24751,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(284 /* CaseClause */); + var node = createBaseNode(285 /* CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -24398,7 +24768,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(285 /* DefaultClause */); + var node = createBaseNode(286 /* DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -24411,13 +24781,13 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(286 /* HeritageClause */); + var node = createBaseNode(287 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { case 93 /* ExtendsKeyword */: - node.transformFlags |= 256 /* ContainsES2015 */; + node.transformFlags |= 512 /* ContainsES2015 */; break; case 116 /* ImplementsKeyword */: node.transformFlags |= 1 /* ContainsTypeScript */; @@ -24435,7 +24805,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(287 /* CatchClause */); + var node = createBaseNode(288 /* CatchClause */); variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, /*type*/ undefined, @@ -24446,7 +24816,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 16 /* ContainsES2019 */; + node.transformFlags |= 32 /* ContainsES2019 */; return node; } // @api @@ -24461,7 +24831,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(288 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(289 /* PropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); @@ -24491,13 +24861,13 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(289 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(290 /* ShorthandPropertyAssignment */, /*decorators*/ undefined, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 256 /* ContainsES2015 */; + 512 /* ContainsES2015 */; return node; } function finishUpdateShorthandPropertyAssignment(updated, original) { @@ -24523,12 +24893,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(290 /* SpreadAssignment */); + var node = createBaseNode(291 /* SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 32 /* ContainsES2018 */ | - 16384 /* ContainsObjectRestOrSpread */; + 64 /* ContainsES2018 */ | + 32768 /* ContainsObjectRestOrSpread */; return node; } // @api @@ -24542,7 +24912,7 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(291 /* EnumMember */); + var node = createBaseNode(292 /* EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -24563,7 +24933,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(298 /* SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -24580,7 +24950,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = baseFactory.createBaseSourceFileNode(297 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(298 /* SourceFile */); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -24618,7 +24988,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(298 /* Bundle */); + var node = createBaseNode(299 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -24633,7 +25003,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(299 /* UnparsedSource */); + var node = createBaseNode(300 /* UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -24651,28 +25021,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(292 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(293 /* UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(293 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(294 /* UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 295 /* UnparsedInternalText */ : 294 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 296 /* UnparsedInternalText */ : 295 /* UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(296 /* UnparsedSyntheticReference */); + var node = createBaseNode(297 /* UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(300 /* InputFiles */); + var node = createBaseNode(301 /* InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -24683,7 +25053,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(227 /* SyntheticExpression */); + var node = createBaseNode(228 /* SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -24691,7 +25061,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(334 /* SyntaxList */); + var node = createBaseNode(338 /* SyntaxList */); node._children = children; return node; } @@ -24706,7 +25076,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(335 /* NotEmittedStatement */); + var node = createBaseNode(339 /* NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -24720,7 +25090,7 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(336 /* PartiallyEmittedExpression */); + var node = createBaseNode(340 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= @@ -24748,7 +25118,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(337 /* CommaListExpression */); + var node = createBaseNode(341 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -24765,7 +25135,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(339 /* EndOfDeclarationMarker */); + var node = createBaseNode(343 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -24776,14 +25146,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(338 /* MergeDeclarationMarker */); + var node = createBaseNode(342 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(340 /* SyntheticReferenceExpression */); + var node = createBaseNode(344 /* SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -24805,7 +25175,7 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(297 /* SourceFile */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(298 /* SourceFile */) : ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78 /* Identifier */) : ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79 /* PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : @@ -24912,11 +25282,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 207 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 206 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 224 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 225 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 336 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 208 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 207 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 225 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 226 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 340 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -24970,13 +25340,13 @@ var ts; case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -25379,23 +25749,24 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 329 /* JSDocTypeTag */: return "type"; - case 327 /* JSDocReturnTag */: return "returns"; - case 328 /* JSDocThisTag */: return "this"; - case 325 /* JSDocEnumTag */: return "enum"; - case 317 /* JSDocAuthorTag */: return "author"; - case 319 /* JSDocClassTag */: return "class"; - case 320 /* JSDocPublicTag */: return "public"; - case 321 /* JSDocPrivateTag */: return "private"; - case 322 /* JSDocProtectedTag */: return "protected"; - case 323 /* JSDocReadonlyTag */: return "readonly"; - case 330 /* JSDocTemplateTag */: return "template"; - case 331 /* JSDocTypedefTag */: return "typedef"; - case 326 /* JSDocParameterTag */: return "param"; - case 333 /* JSDocPropertyTag */: return "prop"; - case 324 /* JSDocCallbackTag */: return "callback"; - case 315 /* JSDocAugmentsTag */: return "augments"; - case 316 /* JSDocImplementsTag */: return "implements"; + case 333 /* JSDocTypeTag */: return "type"; + case 331 /* JSDocReturnTag */: return "returns"; + case 332 /* JSDocThisTag */: return "this"; + case 329 /* JSDocEnumTag */: return "enum"; + case 320 /* JSDocAuthorTag */: return "author"; + case 322 /* JSDocClassTag */: return "class"; + case 323 /* JSDocPublicTag */: return "public"; + case 324 /* JSDocPrivateTag */: return "private"; + case 325 /* JSDocProtectedTag */: return "protected"; + case 326 /* JSDocReadonlyTag */: return "readonly"; + case 327 /* JSDocOverrideTag */: return "override"; + case 334 /* JSDocTemplateTag */: return "template"; + case 335 /* JSDocTypedefTag */: return "typedef"; + case 330 /* JSDocParameterTag */: return "param"; + case 337 /* JSDocPropertyTag */: return "prop"; + case 328 /* JSDocCallbackTag */: return "callback"; + case 318 /* JSDocAugmentsTag */: return "augments"; + case 319 /* JSDocImplementsTag */: return "implements"; default: return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); } @@ -25448,10 +25819,10 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~8388608 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~16777216 /* ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 4096 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 8192 /* PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) @@ -25475,36 +25846,36 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 172 /* FirstTypeNode */ && kind <= 195 /* LastTypeNode */) { + if (kind >= 173 /* FirstTypeNode */ && kind <= 196 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 199 /* ArrayLiteralExpression */: - return 536879104 /* ArrayLiteralOrCallOrNewExcludes */; - case 256 /* ModuleDeclaration */: - return 546379776 /* ModuleExcludes */; - case 160 /* Parameter */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: + case 200 /* ArrayLiteralExpression */: + return 536887296 /* ArrayLiteralOrCallOrNewExcludes */; + case 257 /* ModuleDeclaration */: + return 555888640 /* ModuleExcludes */; + case 161 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 209 /* ArrowFunction */: - return 547309568 /* ArrowFunctionExcludes */; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - return 547313664 /* FunctionExcludes */; - case 250 /* VariableDeclarationList */: - return 537018368 /* VariableDeclarationListExcludes */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - return 536905728 /* ClassExcludes */; - case 166 /* Constructor */: - return 547311616 /* ConstructorExcludes */; - case 163 /* PropertyDeclaration */: - return 536875008 /* PropertyExcludes */; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return 538923008 /* MethodOrAccessorExcludes */; + case 210 /* ArrowFunction */: + return 557748224 /* ArrowFunctionExcludes */; + case 209 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + return 557756416 /* FunctionExcludes */; + case 251 /* VariableDeclarationList */: + return 537165824 /* VariableDeclarationListExcludes */; + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + return 536940544 /* ClassExcludes */; + case 167 /* Constructor */: + return 557752320 /* ConstructorExcludes */; + case 164 /* PropertyDeclaration */: + return 536879104 /* PropertyExcludes */; + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + return 540975104 /* MethodOrAccessorExcludes */; case 128 /* AnyKeyword */: case 144 /* NumberKeyword */: case 155 /* BigIntKeyword */: @@ -25514,30 +25885,30 @@ var ts; case 131 /* BooleanKeyword */: case 148 /* SymbolKeyword */: case 113 /* VoidKeyword */: - case 159 /* TypeParameter */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 160 /* TypeParameter */: + case 163 /* PropertySignature */: + case 165 /* MethodSignature */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 172 /* IndexSignature */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 200 /* ObjectLiteralExpression */: - return 536922112 /* ObjectLiteralExcludes */; - case 287 /* CatchClause */: - return 536887296 /* CatchClauseExcludes */; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - return 536879104 /* BindingPatternExcludes */; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: - case 336 /* PartiallyEmittedExpression */: - case 207 /* ParenthesizedExpression */: + case 201 /* ObjectLiteralExpression */: + return 536973312 /* ObjectLiteralExcludes */; + case 288 /* CatchClause */: + return 536903680 /* CatchClauseExcludes */; + case 197 /* ObjectBindingPattern */: + case 198 /* ArrayBindingPattern */: + return 536887296 /* BindingPatternExcludes */; + case 207 /* TypeAssertionExpression */: + case 225 /* AsExpression */: + case 340 /* PartiallyEmittedExpression */: + case 208 /* ParenthesizedExpression */: case 105 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -25836,7 +26207,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 === 297 /* SourceFile */) { + if (node.kind === 298 /* 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."); @@ -26323,13 +26694,27 @@ var ts; /*typeArguments*/ undefined, [moduleExpression, exportsExpression]); } // Class Fields Helpers - function createClassPrivateFieldGetHelper(receiver, privateField) { + function createClassPrivateFieldGetHelper(receiver, state, kind, f) { context.requestEmitHelper(ts.classPrivateFieldGetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, [receiver, privateField]); + var args; + if (!f) { + args = [receiver, state, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), /*typeArguments*/ undefined, args); } - function createClassPrivateFieldSetHelper(receiver, privateField, value) { + function createClassPrivateFieldSetHelper(receiver, state, value, kind, f) { context.requestEmitHelper(ts.classPrivateFieldSetHelper); - return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, [receiver, privateField, value]); + var args; + if (!f) { + args = [receiver, state, value, factory.createStringLiteral(kind)]; + } + else { + args = [receiver, state, value, factory.createStringLiteral(kind), f]; + } + return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), /*typeArguments*/ undefined, args); } } ts.createEmitHelperFactory = createEmitHelperFactory; @@ -26569,7 +26954,6 @@ var ts; scoped: false, text: "\n var __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n };" }; - // emit output for the __export helper function ts.exportStarHelper = { name: "typescript:export-star", importName: "__exportStar", @@ -26578,18 +26962,116 @@ var ts; priority: 2, text: "\n var __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n };" }; - // Class fields helpers + /** + * Parameters: + * @param receiver — The object from which the private member will be read. + * @param state — One of the following: + * - A WeakMap used to read a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the getter method, or undefined if the getter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Reading from a private instance field (pre TS 4.3): + * __classPrivateFieldGet(, ) + * + * Reading from a private instance field (TS 4.3+): + * __classPrivateFieldGet(, , "f") + * + * Reading from a private instance get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private instance get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private instance method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + * + * Reading from a private static field (TS 4.3+): + * __classPrivateFieldGet(, , "f", <{ value: any }>) + * + * Reading from a private static get accessor (when defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", ) + * + * Reading from a private static get accessor (when not defined, TS 4.3+): + * __classPrivateFieldGet(, , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Reading from a private static method (TS 4.3+): + * __classPrivateFieldGet(, , "m", ) + */ ts.classPrivateFieldGetHelper = { name: "typescript:classPrivateFieldGet", importName: "__classPrivateFieldGet", scoped: false, - text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to get private field on non-instance\");\n }\n return privateMap.get(receiver);\n };" + text: "\n var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n };" }; + /** + * Parameters: + * @param receiver — The object on which the private member will be set. + * @param state — One of the following: + * - A WeakMap used to store a private instance field. + * - A WeakSet used as an instance brand for private instance methods and accessors. + * - A function value that should be the undecorated class constructor used to brand check private static fields, methods, and accessors. + * @param value — The value to set. + * @param kind — (optional pre TS 4.3, required for TS 4.3+) One of the following values: + * - undefined — Indicates a private instance field (pre TS 4.3). + * - "f" — Indicates a private field (instance or static). + * - "m" — Indicates a private method (instance or static). + * - "a" — Indicates a private accessor (instance or static). + * @param f — (optional pre TS 4.3) Depends on the arguments for state and kind: + * - If kind is "m", this should be the function corresponding to the static or instance method. + * - If kind is "a", this should be the function corresponding to the setter method, or undefined if the setter was not defined. + * - If kind is "f" and state is a function, this should be an object holding the value of a static field, or undefined if the static field declaration has not yet been evaluated. + * Usage: + * This helper will only ever be used by the compiler in the following ways: + * + * Writing to a private instance field (pre TS 4.3): + * __classPrivateFieldSet(, , ) + * + * Writing to a private instance field (TS 4.3+): + * __classPrivateFieldSet(, , , "f") + * + * Writing to a private instance set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private instance set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private instance method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + * + * Writing to a private static field (TS 4.3+): + * __classPrivateFieldSet(, , , "f", <{ value: any }>) + * + * Writing to a private static set accessor (when defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", ) + * + * Writing to a private static set accessor (when not defined, TS 4.3+): + * __classPrivateFieldSet(, , , "a", void 0) + * NOTE: This always results in a runtime error. + * + * Writing to a private static method (TS 4.3+): + * __classPrivateFieldSet(, , , "m", ) + * NOTE: This always results in a runtime error. + */ ts.classPrivateFieldSetHelper = { name: "typescript:classPrivateFieldSet", importName: "__classPrivateFieldSet", scoped: false, - text: "\n var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {\n if (!privateMap.has(receiver)) {\n throw new TypeError(\"attempted to set private field on non-instance\");\n }\n privateMap.set(receiver, value);\n return value;\n };" + 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 };" }; var allUnscopedEmitHelpers; function getAllUnscopedEmitHelpers() { @@ -26678,25 +27160,93 @@ var ts; return node.kind === 17 /* TemplateTail */; } ts.isTemplateTail = isTemplateTail; + // Punctuation + function isDotDotDotToken(node) { + return node.kind === 25 /* DotDotDotToken */; + } + ts.isDotDotDotToken = isDotDotDotToken; + /*@internal*/ + function isCommaToken(node) { + return node.kind === 27 /* CommaToken */; + } + ts.isCommaToken = isCommaToken; + function isPlusToken(node) { + return node.kind === 39 /* PlusToken */; + } + ts.isPlusToken = isPlusToken; + function isMinusToken(node) { + return node.kind === 40 /* MinusToken */; + } + ts.isMinusToken = isMinusToken; + function isAsteriskToken(node) { + return node.kind === 41 /* AsteriskToken */; + } + ts.isAsteriskToken = isAsteriskToken; + /*@internal*/ + function isExclamationToken(node) { + return node.kind === 53 /* ExclamationToken */; + } + ts.isExclamationToken = isExclamationToken; + /*@internal*/ + function isQuestionToken(node) { + return node.kind === 57 /* QuestionToken */; + } + ts.isQuestionToken = isQuestionToken; + /*@internal*/ + function isColonToken(node) { + return node.kind === 58 /* ColonToken */; + } + ts.isColonToken = isColonToken; + /*@internal*/ + function isQuestionDotToken(node) { + return node.kind === 28 /* QuestionDotToken */; + } + ts.isQuestionDotToken = isQuestionDotToken; + /*@internal*/ + function isEqualsGreaterThanToken(node) { + return node.kind === 38 /* EqualsGreaterThanToken */; + } + ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { return node.kind === 78 /* Identifier */; } ts.isIdentifier = isIdentifier; - // Names - function isQualifiedName(node) { - return node.kind === 157 /* QualifiedName */; - } - ts.isQualifiedName = isQualifiedName; - function isComputedPropertyName(node) { - return node.kind === 158 /* ComputedPropertyName */; - } - ts.isComputedPropertyName = isComputedPropertyName; function isPrivateIdentifier(node) { return node.kind === 79 /* PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; - // Tokens + // Reserved Words + /* @internal */ + function isExportModifier(node) { + return node.kind === 92 /* ExportKeyword */; + } + ts.isExportModifier = isExportModifier; + /* @internal */ + function isAsyncModifier(node) { + return node.kind === 129 /* AsyncKeyword */; + } + ts.isAsyncModifier = isAsyncModifier; + /* @internal */ + function isAssertsKeyword(node) { + return node.kind === 127 /* AssertsKeyword */; + } + ts.isAssertsKeyword = isAssertsKeyword; + /* @internal */ + function isAwaitKeyword(node) { + return node.kind === 130 /* AwaitKeyword */; + } + ts.isAwaitKeyword = isAwaitKeyword; + /* @internal */ + function isReadonlyKeyword(node) { + return node.kind === 142 /* ReadonlyKeyword */; + } + ts.isReadonlyKeyword = isReadonlyKeyword; + /* @internal */ + function isStaticModifier(node) { + return node.kind === 123 /* StaticKeyword */; + } + ts.isStaticModifier = isStaticModifier; /*@internal*/ function isSuperKeyword(node) { return node.kind === 105 /* SuperKeyword */; @@ -26707,597 +27257,591 @@ var ts; return node.kind === 99 /* ImportKeyword */; } ts.isImportKeyword = isImportKeyword; - /*@internal*/ - function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; - } - ts.isCommaToken = isCommaToken; - /*@internal*/ - function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + // Names + function isQualifiedName(node) { + return node.kind === 158 /* QualifiedName */; } - ts.isQuestionToken = isQuestionToken; - /*@internal*/ - function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + ts.isQualifiedName = isQualifiedName; + function isComputedPropertyName(node) { + return node.kind === 159 /* ComputedPropertyName */; } - ts.isExclamationToken = isExclamationToken; + ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 159 /* TypeParameter */; + return node.kind === 160 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 160 /* Parameter */; + return node.kind === 161 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 161 /* Decorator */; + return node.kind === 162 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 162 /* PropertySignature */; + return node.kind === 163 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 163 /* PropertyDeclaration */; + return node.kind === 164 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 164 /* MethodSignature */; + return node.kind === 165 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 166 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 166 /* Constructor */; + return node.kind === 167 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 167 /* GetAccessor */; + return node.kind === 168 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 168 /* SetAccessor */; + return node.kind === 169 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 169 /* CallSignature */; + return node.kind === 170 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 170 /* ConstructSignature */; + return node.kind === 171 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 171 /* IndexSignature */; + return node.kind === 172 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 172 /* TypePredicate */; + return node.kind === 173 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 173 /* TypeReference */; + return node.kind === 174 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 174 /* FunctionType */; + return node.kind === 175 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 175 /* ConstructorType */; + return node.kind === 176 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 176 /* TypeQuery */; + return node.kind === 177 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 177 /* TypeLiteral */; + return node.kind === 178 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 178 /* ArrayType */; + return node.kind === 179 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 179 /* TupleType */; + return node.kind === 180 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 192 /* NamedTupleMember */; + return node.kind === 193 /* NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 180 /* OptionalType */; + return node.kind === 181 /* OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 181 /* RestType */; + return node.kind === 182 /* RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 182 /* UnionType */; + return node.kind === 183 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 183 /* IntersectionType */; + return node.kind === 184 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 184 /* ConditionalType */; + return node.kind === 185 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 185 /* InferType */; + return node.kind === 186 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 186 /* ParenthesizedType */; + return node.kind === 187 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 187 /* ThisType */; + return node.kind === 188 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 188 /* TypeOperator */; + return node.kind === 189 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 189 /* IndexedAccessType */; + return node.kind === 190 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 190 /* MappedType */; + return node.kind === 191 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 191 /* LiteralType */; + return node.kind === 192 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 195 /* ImportType */; + return node.kind === 196 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 194 /* TemplateLiteralTypeSpan */; + return node.kind === 195 /* TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 193 /* TemplateLiteralType */; + return node.kind === 194 /* TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 196 /* ObjectBindingPattern */; + return node.kind === 197 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 197 /* ArrayBindingPattern */; + return node.kind === 198 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 198 /* BindingElement */; + return node.kind === 199 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 199 /* ArrayLiteralExpression */; + return node.kind === 200 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 200 /* ObjectLiteralExpression */; + return node.kind === 201 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 201 /* PropertyAccessExpression */; + return node.kind === 202 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 202 /* ElementAccessExpression */; + return node.kind === 203 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 203 /* CallExpression */; + return node.kind === 204 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 204 /* NewExpression */; + return node.kind === 205 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 205 /* TaggedTemplateExpression */; + return node.kind === 206 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 207 /* TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 207 /* ParenthesizedExpression */; + return node.kind === 208 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 208 /* FunctionExpression */; + return node.kind === 209 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 209 /* ArrowFunction */; + return node.kind === 210 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 210 /* DeleteExpression */; + return node.kind === 211 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 211 /* TypeOfExpression */; + return node.kind === 212 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 212 /* VoidExpression */; + return node.kind === 213 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 213 /* AwaitExpression */; + return node.kind === 214 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 214 /* PrefixUnaryExpression */; + return node.kind === 215 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 215 /* PostfixUnaryExpression */; + return node.kind === 216 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 216 /* BinaryExpression */; + return node.kind === 217 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 217 /* ConditionalExpression */; + return node.kind === 218 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 218 /* TemplateExpression */; + return node.kind === 219 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 219 /* YieldExpression */; + return node.kind === 220 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 220 /* SpreadElement */; + return node.kind === 221 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 221 /* ClassExpression */; + return node.kind === 222 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 222 /* OmittedExpression */; + return node.kind === 223 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 223 /* ExpressionWithTypeArguments */; + return node.kind === 224 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 224 /* AsExpression */; + return node.kind === 225 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 225 /* NonNullExpression */; + return node.kind === 226 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 226 /* MetaProperty */; + return node.kind === 227 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 227 /* SyntheticExpression */; + return node.kind === 228 /* SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 336 /* PartiallyEmittedExpression */; + return node.kind === 340 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 337 /* CommaListExpression */; + return node.kind === 341 /* CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 228 /* TemplateSpan */; + return node.kind === 229 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 229 /* SemicolonClassElement */; + return node.kind === 230 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 230 /* Block */; + return node.kind === 231 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 232 /* VariableStatement */; + return node.kind === 233 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 231 /* EmptyStatement */; + return node.kind === 232 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 233 /* ExpressionStatement */; + return node.kind === 234 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 234 /* IfStatement */; + return node.kind === 235 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 235 /* DoStatement */; + return node.kind === 236 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 236 /* WhileStatement */; + return node.kind === 237 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 237 /* ForStatement */; + return node.kind === 238 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 238 /* ForInStatement */; + return node.kind === 239 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 239 /* ForOfStatement */; + return node.kind === 240 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 240 /* ContinueStatement */; + return node.kind === 241 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 241 /* BreakStatement */; + return node.kind === 242 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 242 /* ReturnStatement */; + return node.kind === 243 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 243 /* WithStatement */; + return node.kind === 244 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 244 /* SwitchStatement */; + return node.kind === 245 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 245 /* LabeledStatement */; + return node.kind === 246 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 246 /* ThrowStatement */; + return node.kind === 247 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 247 /* TryStatement */; + return node.kind === 248 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 248 /* DebuggerStatement */; + return node.kind === 249 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 249 /* VariableDeclaration */; + return node.kind === 250 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 250 /* VariableDeclarationList */; + return node.kind === 251 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 251 /* FunctionDeclaration */; + return node.kind === 252 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 252 /* ClassDeclaration */; + return node.kind === 253 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 253 /* InterfaceDeclaration */; + return node.kind === 254 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 254 /* TypeAliasDeclaration */; + return node.kind === 255 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 255 /* EnumDeclaration */; + return node.kind === 256 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */; + return node.kind === 257 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 257 /* ModuleBlock */; + return node.kind === 258 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 258 /* CaseBlock */; + return node.kind === 259 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 259 /* NamespaceExportDeclaration */; + return node.kind === 260 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */; + return node.kind === 261 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 261 /* ImportDeclaration */; + return node.kind === 262 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 262 /* ImportClause */; + return node.kind === 263 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 263 /* NamespaceImport */; + return node.kind === 264 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 269 /* NamespaceExport */; + return node.kind === 270 /* NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 264 /* NamedImports */; + return node.kind === 265 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 265 /* ImportSpecifier */; + return node.kind === 266 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 266 /* ExportAssignment */; + return node.kind === 267 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 267 /* ExportDeclaration */; + return node.kind === 268 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 268 /* NamedExports */; + return node.kind === 269 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 270 /* ExportSpecifier */; + return node.kind === 271 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 271 /* MissingDeclaration */; + return node.kind === 272 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 335 /* NotEmittedStatement */; + return node.kind === 339 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 340 /* SyntheticReferenceExpression */; + return node.kind === 344 /* SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 338 /* MergeDeclarationMarker */; + return node.kind === 342 /* MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 339 /* EndOfDeclarationMarker */; + return node.kind === 343 /* EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 272 /* ExternalModuleReference */; + return node.kind === 273 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 273 /* JsxElement */; + return node.kind === 274 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 274 /* JsxSelfClosingElement */; + return node.kind === 275 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 275 /* JsxOpeningElement */; + return node.kind === 276 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 276 /* JsxClosingElement */; + return node.kind === 277 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 277 /* JsxFragment */; + return node.kind === 278 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 278 /* JsxOpeningFragment */; + return node.kind === 279 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 279 /* JsxClosingFragment */; + return node.kind === 280 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 280 /* JsxAttribute */; + return node.kind === 281 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 281 /* JsxAttributes */; + return node.kind === 282 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 282 /* JsxSpreadAttribute */; + return node.kind === 283 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 283 /* JsxExpression */; + return node.kind === 284 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 284 /* CaseClause */; + return node.kind === 285 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 285 /* DefaultClause */; + return node.kind === 286 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 286 /* HeritageClause */; + return node.kind === 287 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 287 /* CatchClause */; + return node.kind === 288 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 288 /* PropertyAssignment */; + return node.kind === 289 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 289 /* ShorthandPropertyAssignment */; + return node.kind === 290 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 290 /* SpreadAssignment */; + return node.kind === 291 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 292 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 293 /* UnparsedPrepend */; + return node.kind === 294 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -27305,156 +27849,164 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 297 /* SourceFile */; + return node.kind === 298 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 298 /* Bundle */; + return node.kind === 299 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 299 /* UnparsedSource */; + return node.kind === 300 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 301 /* JSDocTypeExpression */; + return node.kind === 302 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 302 /* JSDocNameReference */; + return node.kind === 303 /* JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; + function isJSDocLink(node) { + return node.kind === 316 /* JSDocLink */; + } + ts.isJSDocLink = isJSDocLink; function isJSDocAllType(node) { - return node.kind === 303 /* JSDocAllType */; + return node.kind === 304 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 304 /* JSDocUnknownType */; + return node.kind === 305 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 305 /* JSDocNullableType */; + return node.kind === 306 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 306 /* JSDocNonNullableType */; + return node.kind === 307 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 307 /* JSDocOptionalType */; + return node.kind === 308 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 308 /* JSDocFunctionType */; + return node.kind === 309 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 309 /* JSDocVariadicType */; + return node.kind === 310 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 310 /* JSDocNamepathType */; + return node.kind === 311 /* JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 311 /* JSDocComment */; + return node.kind === 312 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 312 /* JSDocTypeLiteral */; + return node.kind === 314 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 313 /* JSDocSignature */; + return node.kind === 315 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 315 /* JSDocAugmentsTag */; + return node.kind === 318 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 317 /* JSDocAuthorTag */; + return node.kind === 320 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 319 /* JSDocClassTag */; + return node.kind === 322 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 324 /* JSDocCallbackTag */; + return node.kind === 328 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 320 /* JSDocPublicTag */; + return node.kind === 323 /* JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 321 /* JSDocPrivateTag */; + return node.kind === 324 /* JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 322 /* JSDocProtectedTag */; + return node.kind === 325 /* JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 323 /* JSDocReadonlyTag */; + return node.kind === 326 /* JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; + function isJSDocOverrideTag(node) { + return node.kind === 327 /* JSDocOverrideTag */; + } + ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 318 /* JSDocDeprecatedTag */; + return node.kind === 321 /* JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 332 /* JSDocSeeTag */; + return node.kind === 336 /* JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 325 /* JSDocEnumTag */; + return node.kind === 329 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 326 /* JSDocParameterTag */; + return node.kind === 330 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 327 /* JSDocReturnTag */; + return node.kind === 331 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 328 /* JSDocThisTag */; + return node.kind === 332 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 329 /* JSDocTypeTag */; + return node.kind === 333 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 330 /* JSDocTemplateTag */; + return node.kind === 334 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 331 /* JSDocTypedefTag */; + return node.kind === 335 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 314 /* JSDocTag */; + return node.kind === 317 /* JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 333 /* JSDocPropertyTag */; + return node.kind === 337 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 316 /* JSDocImplementsTag */; + return node.kind === 319 /* JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 334 /* SyntaxList */; + return n.kind === 338 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -27471,7 +28023,7 @@ var ts; return ts.setTextRange(factory.createElementAccessExpression(target, memberName.expression), location); } else { - var expression = ts.setTextRange(ts.isIdentifierOrPrivateIdentifier(memberName) + var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; @@ -27653,14 +28205,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -27713,21 +28265,21 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 337 /* CommaListExpression */; + return node.kind === 217 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 341 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 15 /* All */; } switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 207 /* TypeAssertionExpression */: + case 225 /* AsExpression */: return (kinds & 2 /* TypeAssertions */) !== 0; - case 225 /* NonNullExpression */: + case 226 /* NonNullExpression */: return (kinds & 4 /* NonNullAssertions */) !== 0; - case 336 /* PartiallyEmittedExpression */: + case 340 /* PartiallyEmittedExpression */: return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -27848,10 +28400,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 261 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 262 /* ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 267 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 268 /* ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -27970,7 +28522,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -27982,11 +28534,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 290 /* SpreadAssignment */: + case 291 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -28018,12 +28570,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 160 /* Parameter */: - case 198 /* BindingElement */: + case 161 /* Parameter */: + case 199 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 220 /* SpreadElement */: - case 290 /* SpreadAssignment */: + case 221 /* SpreadElement */: + case 291 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -28041,7 +28593,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 198 /* BindingElement */: + case 199 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -28056,7 +28608,7 @@ var ts; : propertyName; } break; - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -28071,7 +28623,7 @@ var ts; : propertyName; } break; - case 290 /* SpreadAssignment */: + case 291 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -28094,13 +28646,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: - case 199 /* ArrayLiteralExpression */: + case 197 /* ObjectBindingPattern */: + case 198 /* ArrayBindingPattern */: + case 200 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -28121,46 +28673,294 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveModifiers(node) { var kind = node.kind; - return kind === 160 /* Parameter */ - || kind === 162 /* PropertySignature */ - || kind === 163 /* PropertyDeclaration */ - || kind === 164 /* MethodSignature */ - || kind === 165 /* MethodDeclaration */ - || kind === 166 /* Constructor */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 171 /* IndexSignature */ - || kind === 208 /* FunctionExpression */ - || kind === 209 /* ArrowFunction */ - || kind === 221 /* ClassExpression */ - || kind === 232 /* VariableStatement */ - || kind === 251 /* FunctionDeclaration */ - || kind === 252 /* ClassDeclaration */ - || kind === 253 /* InterfaceDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 255 /* EnumDeclaration */ - || kind === 256 /* ModuleDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 266 /* ExportAssignment */ - || kind === 267 /* ExportDeclaration */; + return kind === 161 /* Parameter */ + || kind === 163 /* PropertySignature */ + || kind === 164 /* PropertyDeclaration */ + || kind === 165 /* MethodSignature */ + || kind === 166 /* MethodDeclaration */ + || kind === 167 /* Constructor */ + || kind === 168 /* GetAccessor */ + || kind === 169 /* SetAccessor */ + || kind === 172 /* IndexSignature */ + || kind === 209 /* FunctionExpression */ + || kind === 210 /* ArrowFunction */ + || kind === 222 /* ClassExpression */ + || kind === 233 /* VariableStatement */ + || kind === 252 /* FunctionDeclaration */ + || kind === 253 /* ClassDeclaration */ + || kind === 254 /* InterfaceDeclaration */ + || kind === 255 /* TypeAliasDeclaration */ + || kind === 256 /* EnumDeclaration */ + || kind === 257 /* ModuleDeclaration */ + || kind === 261 /* ImportEqualsDeclaration */ + || kind === 262 /* ImportDeclaration */ + || kind === 267 /* ExportAssignment */ + || kind === 268 /* ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; - /* @internal */ - function isExportModifier(node) { - return node.kind === 92 /* ExportKeyword */; - } - ts.isExportModifier = isExportModifier; - /* @internal */ - function isAsyncModifier(node) { - return node.kind === 129 /* AsyncKeyword */; - } - ts.isAsyncModifier = isAsyncModifier; - /* @internal */ - function isStaticModifier(node) { - return node.kind === 123 /* StaticKeyword */; + ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); + ts.isQuestionOrExclamationToken = ts.or(ts.isQuestionToken, ts.isExclamationToken); + ts.isIdentifierOrThisTypeNode = ts.or(ts.isIdentifier, ts.isThisTypeNode); + ts.isReadonlyKeywordOrPlusOrMinusToken = ts.or(ts.isReadonlyKeyword, ts.isPlusToken, ts.isMinusToken); + ts.isQuestionOrPlusOrMinusToken = ts.or(ts.isQuestionToken, ts.isPlusToken, ts.isMinusToken); + ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); + function isLiteralTypeLikeExpression(node) { + var kind = node.kind; + return kind === 103 /* NullKeyword */ + || kind === 109 /* TrueKeyword */ + || kind === 94 /* FalseKeyword */ + || ts.isLiteralExpression(node) + || ts.isPrefixUnaryExpression(node); + } + ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; + function isExponentiationOperator(kind) { + return kind === 42 /* AsteriskAsteriskToken */; + } + function isMultiplicativeOperator(kind) { + return kind === 41 /* AsteriskToken */ + || kind === 43 /* SlashToken */ + || kind === 44 /* PercentToken */; + } + function isMultiplicativeOperatorOrHigher(kind) { + return isExponentiationOperator(kind) + || isMultiplicativeOperator(kind); + } + function isAdditiveOperator(kind) { + return kind === 39 /* PlusToken */ + || kind === 40 /* MinusToken */; + } + function isAdditiveOperatorOrHigher(kind) { + return isAdditiveOperator(kind) + || isMultiplicativeOperatorOrHigher(kind); + } + function isShiftOperator(kind) { + return kind === 47 /* LessThanLessThanToken */ + || kind === 48 /* GreaterThanGreaterThanToken */ + || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + } + function isShiftOperatorOrHigher(kind) { + return isShiftOperator(kind) + || isAdditiveOperatorOrHigher(kind); + } + function isRelationalOperator(kind) { + return kind === 29 /* LessThanToken */ + || kind === 32 /* LessThanEqualsToken */ + || kind === 31 /* GreaterThanToken */ + || kind === 33 /* GreaterThanEqualsToken */ + || kind === 101 /* InstanceOfKeyword */ + || kind === 100 /* InKeyword */; + } + function isRelationalOperatorOrHigher(kind) { + return isRelationalOperator(kind) + || isShiftOperatorOrHigher(kind); + } + function isEqualityOperator(kind) { + return kind === 34 /* EqualsEqualsToken */ + || kind === 36 /* EqualsEqualsEqualsToken */ + || kind === 35 /* ExclamationEqualsToken */ + || kind === 37 /* ExclamationEqualsEqualsToken */; + } + function isEqualityOperatorOrHigher(kind) { + return isEqualityOperator(kind) + || isRelationalOperatorOrHigher(kind); + } + function isBitwiseOperator(kind) { + return kind === 50 /* AmpersandToken */ + || kind === 51 /* BarToken */ + || kind === 52 /* CaretToken */; + } + function isBitwiseOperatorOrHigher(kind) { + return isBitwiseOperator(kind) + || isEqualityOperatorOrHigher(kind); + } + // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. + function isLogicalOperator(kind) { + return kind === 55 /* AmpersandAmpersandToken */ + || kind === 56 /* BarBarToken */; + } + function isLogicalOperatorOrHigher(kind) { + return isLogicalOperator(kind) + || isBitwiseOperatorOrHigher(kind); + } + function isAssignmentOperatorOrHigher(kind) { + return kind === 60 /* QuestionQuestionToken */ + || isLogicalOperatorOrHigher(kind) + || ts.isAssignmentOperator(kind); + } + function isBinaryOperator(kind) { + return isAssignmentOperatorOrHigher(kind) + || kind === 27 /* CommaToken */; + } + function isBinaryOperatorToken(node) { + return isBinaryOperator(node.kind); + } + ts.isBinaryOperatorToken = isBinaryOperatorToken; + var BinaryExpressionState; + (function (BinaryExpressionState) { + /** + * Handles walking into a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function enter(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, outerState) { + var prevUserState = stackIndex > 0 ? userStateStack[stackIndex - 1] : undefined; + ts.Debug.assertEqual(stateStack[stackIndex], enter); + userStateStack[stackIndex] = machine.onEnter(nodeStack[stackIndex], prevUserState, outerState); + stateStack[stackIndex] = nextState(machine, enter); + return stackIndex; + } + BinaryExpressionState.enter = enter; + /** + * Handles walking the `left` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function left(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], left); + ts.Debug.assertIsDefined(machine.onLeft); + stateStack[stackIndex] = nextState(machine, left); + var nextNode = machine.onLeft(nodeStack[stackIndex].left, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.left = left; + /** + * Handles walking the `operatorToken` of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function operator(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], operator); + ts.Debug.assertIsDefined(machine.onOperator); + stateStack[stackIndex] = nextState(machine, operator); + machine.onOperator(nodeStack[stackIndex].operatorToken, userStateStack[stackIndex], nodeStack[stackIndex]); + return stackIndex; + } + BinaryExpressionState.operator = operator; + /** + * Handles walking the `right` side of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function right(machine, stackIndex, stateStack, nodeStack, userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], right); + ts.Debug.assertIsDefined(machine.onRight); + stateStack[stackIndex] = nextState(machine, right); + var nextNode = machine.onRight(nodeStack[stackIndex].right, userStateStack[stackIndex], nodeStack[stackIndex]); + if (nextNode) { + checkCircularity(stackIndex, nodeStack, nextNode); + return pushStack(stackIndex, stateStack, nodeStack, userStateStack, nextNode); + } + return stackIndex; + } + BinaryExpressionState.right = right; + /** + * Handles walking out of a `BinaryExpression`. + * @param machine State machine handler functions + * @param frame The current frame + * @returns The new frame + */ + function exit(machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], exit); + stateStack[stackIndex] = nextState(machine, exit); + var result = machine.onExit(nodeStack[stackIndex], userStateStack[stackIndex]); + if (stackIndex > 0) { + stackIndex--; + if (machine.foldState) { + var side = stateStack[stackIndex] === exit ? "right" : "left"; + userStateStack[stackIndex] = machine.foldState(userStateStack[stackIndex], result, side); + } + } + else { + resultHolder.value = result; + } + return stackIndex; + } + BinaryExpressionState.exit = exit; + /** + * Handles a frame that is already done. + * @returns The `done` state. + */ + function done(_machine, stackIndex, stateStack, _nodeStack, _userStateStack, _resultHolder, _outerState) { + ts.Debug.assertEqual(stateStack[stackIndex], done); + return stackIndex; + } + BinaryExpressionState.done = done; + function nextState(machine, currentState) { + switch (currentState) { + case enter: + if (machine.onLeft) + return left; + // falls through + case left: + if (machine.onOperator) + return operator; + // falls through + case operator: + if (machine.onRight) + return right; + // falls through + case right: return exit; + case exit: return done; + case done: return done; + default: ts.Debug.fail("Invalid state"); + } + } + BinaryExpressionState.nextState = nextState; + function pushStack(stackIndex, stateStack, nodeStack, userStateStack, node) { + stackIndex++; + stateStack[stackIndex] = enter; + nodeStack[stackIndex] = node; + userStateStack[stackIndex] = undefined; + return stackIndex; + } + function checkCircularity(stackIndex, nodeStack, node) { + if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + while (stackIndex >= 0) { + ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); + stackIndex--; + } + } + } + })(BinaryExpressionState || (BinaryExpressionState = {})); + /** + * Holds state machine handler functions + */ + var BinaryExpressionStateMachine = /** @class */ (function () { + function BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + this.onEnter = onEnter; + this.onLeft = onLeft; + this.onOperator = onOperator; + this.onRight = onRight; + this.onExit = onExit; + this.foldState = foldState; + } + return BinaryExpressionStateMachine; + }()); + function createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState) { + var machine = new BinaryExpressionStateMachine(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return trampoline; + function trampoline(node, outerState) { + var resultHolder = { value: undefined }; + var stateStack = [BinaryExpressionState.enter]; + var nodeStack = [node]; + var userStateStack = [undefined]; + var stackIndex = 0; + while (stateStack[stackIndex] !== BinaryExpressionState.done) { + stackIndex = stateStack[stackIndex](machine, stackIndex, stateStack, nodeStack, userStateStack, resultHolder, outerState); + } + ts.Debug.assertEqual(stackIndex, 0); + return resultHolder.value; + } } - ts.isStaticModifier = isStaticModifier; + ts.createBinaryExpressionTrampoline = createBinaryExpressionTrampoline; })(ts || (ts = {})); var ts; (function (ts) { @@ -28242,19 +29042,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 <= 156 /* LastToken */) { + if (!node || node.kind <= 157 /* LastToken */) { return; } switch (node.kind) { - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 159 /* TypeParameter */: + case 160 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -28262,9 +29062,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 290 /* SpreadAssignment */: + case 291 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 160 /* Parameter */: + case 161 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -28272,7 +29072,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -28280,51 +29080,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 162 /* PropertySignature */: + case 163 /* 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 288 /* PropertyAssignment */: + case 289 /* 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 249 /* VariableDeclaration */: + case 250 /* 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 198 /* BindingElement */: + case 199 /* 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 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 172 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 209 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 210 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -28336,374 +29136,390 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 173 /* TypeReference */: + case 174 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172 /* TypePredicate */: + case 173 /* TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 176 /* TypeQuery */: + case 177 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 177 /* TypeLiteral */: + case 178 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 178 /* ArrayType */: + case 179 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 179 /* TupleType */: + case 180 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 183 /* UnionType */: + case 184 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 184 /* ConditionalType */: + case 185 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 185 /* InferType */: + case 186 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 195 /* ImportType */: + case 196 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 186 /* ParenthesizedType */: - case 188 /* TypeOperator */: + case 187 /* ParenthesizedType */: + case 189 /* TypeOperator */: return visitNode(cbNode, node.type); - case 189 /* IndexedAccessType */: + case 190 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 190 /* MappedType */: + case 191 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 191 /* LiteralType */: + case 192 /* LiteralType */: return visitNode(cbNode, node.literal); - case 192 /* NamedTupleMember */: + case 193 /* NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 197 /* ObjectBindingPattern */: + case 198 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 206 /* TypeAssertionExpression */: + case 207 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 210 /* DeleteExpression */: + case 211 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 211 /* TypeOfExpression */: + case 212 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 212 /* VoidExpression */: + case 213 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 219 /* YieldExpression */: + case 220 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 213 /* AwaitExpression */: + case 214 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 224 /* AsExpression */: + case 225 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 225 /* NonNullExpression */: + case 226 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 226 /* MetaProperty */: + case 227 /* MetaProperty */: return visitNode(cbNode, node.name); - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 220 /* SpreadElement */: + case 221 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 231 /* Block */: + case 258 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 297 /* SourceFile */: + case 298 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 250 /* VariableDeclarationList */: + case 251 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 234 /* IfStatement */: + case 235 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 235 /* DoStatement */: + case 236 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 236 /* WhileStatement */: + case 237 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 239 /* ForOfStatement */: + case 240 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 241 /* ContinueStatement */: + case 242 /* BreakStatement */: return visitNode(cbNode, node.label); - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 243 /* WithStatement */: + case 244 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 258 /* CaseBlock */: + case 259 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 284 /* CaseClause */: + case 285 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 285 /* DefaultClause */: + case 286 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 246 /* ThrowStatement */: + case 247 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 247 /* TryStatement */: + case 248 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 287 /* CatchClause */: + case 288 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 161 /* Decorator */: + case 162 /* Decorator */: return visitNode(cbNode, node.expression); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 222 /* 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 253 /* InterfaceDeclaration */: + case 254 /* 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 254 /* TypeAliasDeclaration */: + case 255 /* 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 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 291 /* EnumMember */: + case 292 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 262 /* ImportClause */: + case 263 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 259 /* NamespaceExportDeclaration */: + case 260 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 269 /* NamespaceExport */: + case 270 /* NamespaceExport */: return visitNode(cbNode, node.name); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 265 /* NamedImports */: + case 269 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 266 /* ImportSpecifier */: + case 271 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 218 /* TemplateExpression */: + case 219 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 228 /* TemplateSpan */: + case 229 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 193 /* TemplateLiteralType */: + case 194 /* TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 194 /* TemplateLiteralTypeSpan */: + case 195 /* TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 286 /* HeritageClause */: + case 287 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 272 /* ExternalModuleReference */: + case 273 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 271 /* MissingDeclaration */: + case 272 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 337 /* CommaListExpression */: + case 341 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 273 /* JsxElement */: + case 274 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 277 /* JsxFragment */: + case 278 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 275 /* JsxSelfClosingElement */: + case 276 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 281 /* JsxAttributes */: + case 282 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 280 /* JsxAttribute */: + case 281 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 282 /* JsxSpreadAttribute */: + case 283 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 276 /* JsxClosingElement */: + case 277 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 180 /* OptionalType */: - case 181 /* RestType */: - case 301 /* JSDocTypeExpression */: - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 307 /* JSDocOptionalType */: - case 309 /* JSDocVariadicType */: + case 181 /* OptionalType */: + case 182 /* RestType */: + case 302 /* JSDocTypeExpression */: + case 307 /* JSDocNonNullableType */: + case 306 /* JSDocNullableType */: + case 308 /* JSDocOptionalType */: + case 310 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 308 /* JSDocFunctionType */: + case 309 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 311 /* JSDocComment */: - return visitNodes(cbNode, cbNodes, node.tags); - case 332 /* JSDocSeeTag */: + case 312 /* JSDocComment */: + return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) + || visitNodes(cbNode, cbNodes, node.tags); + case 336 /* JSDocSeeTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.name); - case 302 /* JSDocNameReference */: + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 303 /* JSDocNameReference */: return visitNode(cbNode, node.name); - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 330 /* JSDocParameterTag */: + case 337 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || - visitNode(cbNode, node.typeExpression) + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)); - case 317 /* JSDocAuthorTag */: - return visitNode(cbNode, node.tagName); - case 316 /* JSDocImplementsTag */: + visitNode(cbNode, node.name)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 315 /* JSDocAugmentsTag */: + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 319 /* JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.class); - case 330 /* JSDocTemplateTag */: + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 318 /* JSDocAugmentsTag */: + return visitNode(cbNode, node.tagName) || + visitNode(cbNode, node.class) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 334 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || - visitNodes(cbNode, cbNodes, node.typeParameters); - case 331 /* JSDocTypedefTag */: + visitNodes(cbNode, cbNodes, node.typeParameters) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 335 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 301 /* JSDocTypeExpression */ + node.typeExpression.kind === 302 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.fullName) + visitNode(cbNode, node.fullName) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression)); - case 324 /* JSDocCallbackTag */: + visitNode(cbNode, node.typeExpression)) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 328 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || - visitNode(cbNode, node.typeExpression); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 331 /* JSDocReturnTag */: + case 333 /* JSDocTypeTag */: + case 332 /* JSDocThisTag */: + case 329 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || - visitNode(cbNode, node.typeExpression); - case 313 /* JSDocSignature */: + visitNode(cbNode, node.typeExpression) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 315 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 312 /* JSDocTypeLiteral */: + case 316 /* JSDocLink */: + return visitNode(cbNode, node.name); + case 314 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 314 /* JSDocTag */: - case 319 /* JSDocClassTag */: - case 320 /* JSDocPublicTag */: - case 321 /* JSDocPrivateTag */: - case 322 /* JSDocProtectedTag */: - case 323 /* JSDocReadonlyTag */: - return visitNode(cbNode, node.tagName); - case 336 /* PartiallyEmittedExpression */: + case 317 /* JSDocTag */: + case 322 /* JSDocClassTag */: + case 323 /* JSDocPublicTag */: + case 324 /* JSDocPrivateTag */: + case 325 /* JSDocProtectedTag */: + case 326 /* JSDocReadonlyTag */: + case 321 /* JSDocDeprecatedTag */: + return visitNode(cbNode, node.tagName) + || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + case 340 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -28752,7 +29568,7 @@ var ts; continue; return res; } - if (current.kind >= 157 /* FirstNode */) { + if (current.kind >= 158 /* 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]; @@ -28969,11 +29785,12 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6 /* JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); - ts.convertToObjectWorker(result_3, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; result_3.typeReferenceDirectives = ts.emptyArray; result_3.libReferenceDirectives = ts.emptyArray; @@ -29013,35 +29830,54 @@ var ts; endOfFileToken = parseTokenNode(); } else { - var expression = void 0; - switch (token()) { - case 22 /* OpenBracketToken */: - expression = parseArrayLiteralExpression(); - break; - case 109 /* TrueKeyword */: - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - expression = parseTokenNode(); - break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { - expression = parsePrefixUnaryExpression(); - } - else { - expression = parseObjectLiteralExpression(); - } - break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { - expression = parseLiteralNode(); + // Loop and synthesize an ArrayLiteralExpression if there are more than + // one top-level expressions to ensure all input text is consumed. + var expressions = void 0; + while (token() !== 1 /* EndOfFileToken */) { + var expression_1 = void 0; + switch (token()) { + case 22 /* OpenBracketToken */: + expression_1 = parseArrayLiteralExpression(); + break; + case 109 /* TrueKeyword */: + case 94 /* FalseKeyword */: + case 103 /* NullKeyword */: + expression_1 = parseTokenNode(); break; + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parsePrefixUnaryExpression(); + } + else { + expression_1 = parseObjectLiteralExpression(); + } + break; + case 8 /* NumericLiteral */: + case 10 /* StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + expression_1 = parseLiteralNode(); + break; + } + // falls through + default: + expression_1 = parseObjectLiteralExpression(); + break; + } + // Error recovery: collect multiple top-level expressions + if (expressions && ts.isArray(expressions)) { + expressions.push(expression_1); + } + else if (expressions) { + expressions = [expressions, expression_1]; + } + else { + expressions = expression_1; + if (token() !== 1 /* EndOfFileToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } - // falls through - default: - expression = parseObjectLiteralExpression(); - break; + } } + var expression = ts.isArray(expressions) ? finishNode(factory.createArrayLiteralExpression(expressions), pos) : ts.Debug.checkDefined(expressions); var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); @@ -29236,7 +30072,7 @@ var ts; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */); + && !!(node.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -29277,7 +30113,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setExternalModuleIndicator(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 8388608 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); } sourceFile.text = sourceText; @@ -29648,7 +30484,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 === 271 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 272 /* MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -30035,8 +30871,7 @@ var ts; var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { - var element = parseListElement(kind, parseElement); - list.push(element); + list.push(parseListElement(kind, parseElement)); continue; } if (abortParsingListOrMoveToNextToken(kind)) { @@ -30186,14 +31021,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 166 /* Constructor */: - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 229 /* SemicolonClassElement */: + case 167 /* Constructor */: + case 172 /* IndexSignature */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 164 /* PropertyDeclaration */: + case 230 /* SemicolonClassElement */: return true; - case 165 /* MethodDeclaration */: + case 166 /* 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. @@ -30208,8 +31043,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: return true; } } @@ -30218,58 +31053,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 232 /* VariableStatement */: - case 230 /* Block */: - case 234 /* IfStatement */: - case 233 /* ExpressionStatement */: - case 246 /* ThrowStatement */: - case 242 /* ReturnStatement */: - case 244 /* SwitchStatement */: - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 231 /* EmptyStatement */: - case 247 /* TryStatement */: - case 245 /* LabeledStatement */: - case 235 /* DoStatement */: - case 248 /* DebuggerStatement */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 252 /* FunctionDeclaration */: + case 233 /* VariableStatement */: + case 231 /* Block */: + case 235 /* IfStatement */: + case 234 /* ExpressionStatement */: + case 247 /* ThrowStatement */: + case 243 /* ReturnStatement */: + case 245 /* SwitchStatement */: + case 242 /* BreakStatement */: + case 241 /* ContinueStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 238 /* ForStatement */: + case 237 /* WhileStatement */: + case 244 /* WithStatement */: + case 232 /* EmptyStatement */: + case 248 /* TryStatement */: + case 246 /* LabeledStatement */: + case 236 /* DoStatement */: + case 249 /* DebuggerStatement */: + case 262 /* ImportDeclaration */: + case 261 /* ImportEqualsDeclaration */: + case 268 /* ExportDeclaration */: + case 267 /* ExportAssignment */: + case 257 /* ModuleDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 256 /* EnumDeclaration */: + case 255 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 291 /* EnumMember */; + return node.kind === 292 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 162 /* PropertySignature */: - case 169 /* CallSignature */: + case 171 /* ConstructSignature */: + case 165 /* MethodSignature */: + case 172 /* IndexSignature */: + case 163 /* PropertySignature */: + case 170 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 249 /* VariableDeclaration */) { + if (node.kind !== 250 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -30290,7 +31125,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 160 /* Parameter */) { + if (node.kind !== 161 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -30571,14 +31406,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 174 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: { + case 175 /* FunctionType */: + case 176 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 186 /* ParenthesizedType */: + case 187 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -30759,19 +31594,21 @@ var ts; function parseParameterWorker(inOuterAwaitContext) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); + // FormalParameter [Yield,Await]: + // BindingElement[?Yield,?Await] + // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. + var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); if (token() === 107 /* ThisKeyword */) { - var node_1 = factory.createParameterDeclaration( - /*decorators*/ undefined, + var node_1 = factory.createParameterDeclaration(decorators, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), /*initializer*/ undefined); + if (decorators) { + parseErrorAtRange(decorators[0], ts.Diagnostics.Decorators_may_not_be_applied_to_this_parameters); + } return withJSDoc(finishNode(node_1, pos), hasJSDoc); } - // FormalParameter [Yield,Await]: - // BindingElement[?Yield,?Await] - // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. - var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); var savedTopLevel = topLevel; topLevel = false; var modifiers = parseModifiers(); @@ -30858,14 +31695,14 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 170 /* ConstructSignature */) { + if (kind === 171 /* ConstructSignature */) { parseExpected(102 /* NewKeyword */); } var typeParameters = parseTypeParameters(); var parameters = parseParameters(4 /* Type */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 169 /* CallSignature */ + var node = kind === 170 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -30956,7 +31793,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || + token() === 29 /* LessThanToken */ || + token() === 134 /* GetKeyword */ || + token() === 146 /* SetKeyword */) { return true; } var idToken = false; @@ -30988,14 +31828,20 @@ var ts; } function parseTypeMember() { if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(169 /* CallSignature */); + return parseSignatureMember(170 /* CallSignature */); } if (token() === 102 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(170 /* ConstructSignature */); + return parseSignatureMember(171 /* ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); + if (parseContextualModifier(134 /* GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 168 /* GetAccessor */); + } + if (parseContextualModifier(146 /* SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 169 /* SetAccessor */); + } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); } @@ -32028,7 +32874,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 100 /* InKeyword */ || t === 156 /* OfKeyword */; + return t === 100 /* InKeyword */ || t === 157 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -32168,7 +33014,7 @@ var ts; if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 206 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 207 /* 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 { @@ -32419,7 +33265,7 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 275 /* JsxOpeningElement */) { + if (opening.kind === 276 /* JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = parseJsxClosingElement(inExpressionContext); if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) { @@ -32427,11 +33273,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 278 /* JsxOpeningFragment */) { + else if (opening.kind === 279 /* JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 274 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 275 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -32931,10 +33777,10 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* GetAccessor */); } if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* SetAccessor */); } var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -33052,6 +33898,7 @@ var ts; // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); @@ -33062,11 +33909,16 @@ var ts; ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); } } - return finishNode(factory.createBlock(statements, multiLine), pos); + var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); + if (token() === 62 /* EqualsToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); + nextToken(); + } + return result; } else { var statements = createMissingList(); - return finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos); + return withJSDoc(finishNode(factory.createBlock(statements, /*multiLine*/ undefined), pos), hasJSDoc); } } function parseFunctionBlock(flags, diagnosticMessage) { @@ -33093,21 +33945,24 @@ var ts; } function parseEmptyStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(26 /* SemicolonToken */); - return finishNode(factory.createEmptyStatement(), pos); + return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(98 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var thenStatement = parseStatement(); var elseStatement = parseOptional(90 /* ElseKeyword */) ? parseStatement() : undefined; - return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos); + return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(89 /* DoKeyword */); var statement = parseStatement(); parseExpected(114 /* WhileKeyword */); @@ -33119,19 +33974,21 @@ var ts; // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. parseOptional(26 /* SemicolonToken */); - return finishNode(factory.createDoStatement(statement, expression), pos); + return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(114 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = parseStatement(); - return finishNode(factory.createWhileStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(96 /* ForKeyword */); var awaitToken = parseOptionalToken(130 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); @@ -33145,7 +34002,7 @@ var ts; } } var node; - if (awaitToken ? parseExpected(156 /* OfKeyword */) : parseOptional(156 /* OfKeyword */)) { + if (awaitToken ? parseExpected(157 /* OfKeyword */) : parseOptional(157 /* OfKeyword */)) { var expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); @@ -33167,33 +34024,36 @@ var ts; parseExpected(21 /* CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); - parseExpected(kind === 241 /* BreakStatement */ ? 80 /* BreakKeyword */ : 85 /* ContinueKeyword */); + var hasJSDoc = hasPrecedingJSDocComment(); + parseExpected(kind === 242 /* BreakStatement */ ? 80 /* BreakKeyword */ : 85 /* ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 241 /* BreakStatement */ + var node = kind === 242 /* BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseReturnStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(104 /* ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); - return finishNode(factory.createReturnStatement(expression), pos); + return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); } function parseWithStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(115 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); - return finishNode(factory.createWithStatement(expression, statement), pos); + return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); @@ -33222,17 +34082,19 @@ var ts; } function parseSwitchStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(106 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); var expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); var caseBlock = parseCaseBlock(); - return finishNode(factory.createSwitchStatement(expression, caseBlock), pos); + return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(108 /* ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' @@ -33245,11 +34107,12 @@ var ts; expression = finishNode(factory.createIdentifier(""), getNodePos()); } parseSemicolon(); - return finishNode(factory.createThrowStatement(expression), pos); + return withJSDoc(finishNode(factory.createThrowStatement(expression), pos), hasJSDoc); } // TODO: Review for error recovery function parseTryStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(110 /* TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); var catchClause = token() === 82 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -33260,7 +34123,7 @@ var ts; parseExpected(95 /* FinallyKeyword */); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } - return finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos); + return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); @@ -33279,9 +34142,10 @@ var ts; } function parseDebuggerStatement() { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); parseExpected(86 /* DebuggerKeyword */); parseSemicolon(); - return finishNode(factory.createDebuggerStatement(), pos); + return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } function parseExpressionOrLabeledStatement() { // Avoiding having to do the lookahead for a labeled statement by just trying to parse @@ -33489,9 +34353,9 @@ var ts; case 96 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 85 /* ContinueKeyword */: - return parseBreakOrContinueStatement(240 /* ContinueStatement */); + return parseBreakOrContinueStatement(241 /* ContinueStatement */); case 80 /* BreakKeyword */: - return parseBreakOrContinueStatement(241 /* BreakStatement */); + return parseBreakOrContinueStatement(242 /* BreakStatement */); case 104 /* ReturnKeyword */: return parseReturnStatement(); case 115 /* WithKeyword */: @@ -33611,7 +34475,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(271 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(272 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -33693,6 +34557,7 @@ var ts; } function parseVariableDeclaration(allowExclamation) { var pos = getNodePos(); + var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; if (allowExclamation && name.kind === 78 /* Identifier */ && @@ -33702,7 +34567,7 @@ var ts; var type = parseTypeAnnotation(); var initializer = isInOrOfKeyword(token()) ? undefined : parseInitializer(); var node = factory.createVariableDeclaration(name, exclamationToken, type, initializer); - return finishNode(node, pos); + return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseVariableDeclarationList(inForStatementInitializer) { var pos = getNodePos(); @@ -33730,7 +34595,7 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 156 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 157 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { @@ -33834,12 +34699,12 @@ var ts; var parameters = parseParameters(0 /* None */); var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 167 /* GetAccessor */ + var node = kind === 168 /* 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 === 168 /* SetAccessor */) + if (type && node.kind === 169 /* SetAccessor */) node.type = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -33982,10 +34847,10 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); if (parseContextualModifier(134 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167 /* GetAccessor */); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* GetAccessor */); } if (parseContextualModifier(146 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168 /* SetAccessor */); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 169 /* SetAccessor */); } if (token() === 132 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -34024,10 +34889,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, 221 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 222 /* ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 252 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 253 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); @@ -34049,7 +34914,7 @@ var ts; members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 252 /* ClassDeclaration */ + var node = kind === 253 /* ClassDeclaration */ ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34288,7 +35153,7 @@ var ts; var namedBindings; if (!identifier || parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(264 /* NamedImports */); + namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(265 /* NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -34336,16 +35201,16 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 264 /* NamedImports */ + var node = kind === 265 /* 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(270 /* ExportSpecifier */); + return parseImportOrExportSpecifier(271 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(265 /* ImportSpecifier */); + return parseImportOrExportSpecifier(266 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -34372,10 +35237,10 @@ var ts; else { name = identifierName; } - if (kind === 265 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 266 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 265 /* ImportSpecifier */ + var node = kind === 266 /* ImportSpecifier */ ? factory.createImportSpecifier(propertyName, name) : factory.createExportSpecifier(propertyName, name); return finishNode(node, pos); @@ -34398,7 +35263,7 @@ var ts; moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(268 /* NamedExports */); + exportClause = parseNamedImportsOrExports(269 /* 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. @@ -34587,7 +35452,10 @@ var ts; var tags; var tagsPos; var tagsEnd; + var linkEnd; + var commentsPos; var comments = []; + var parts = []; // + 3 for leading /**, - 5 in total for /** */ return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. @@ -34616,6 +35484,8 @@ var ts; case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); + if (!commentsPos) + commentsPos = getNodePos(); addTag(parseTag(indent)); // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning @@ -34658,6 +35528,22 @@ var ts; break; case 1 /* EndOfFileToken */: break loop; + case 18 /* OpenBraceToken */: + state = 2 /* SavingComments */; + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + if (!linkEnd) { + removeLeadingNewlines(comments); + } + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + break; + } + // fallthrough if it's not a {@link sequence default: // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next @@ -34668,9 +35554,14 @@ var ts; } nextTokenJSDoc(); } - removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return createJSDocComment(); + if (parts.length && comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : start, commentsPos)); + } + if (parts.length && tags) + ts.Debug.assertIsDefined(commentsPos, "having parsed tags implies that the end of the comment span should be set"); + var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); + return finishNode(factory.createJSDocComment(parts.length ? createNodeArray(parts, start, commentsPos) : comments.length ? comments.join("") : undefined, tagsArray), start, end); }); function removeLeadingNewlines(comments) { while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { @@ -34682,11 +35573,6 @@ var ts; comments.pop(); } } - function createJSDocComment() { - var comment = comments.length ? comments.join("") : undefined; - var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd); - return finishNode(factory.createJSDocComment(comment, tagsArray), start, end); - } function isNextNonwhitespaceTokenEndOfFile() { // We must use infinite lookahead, as there could be any number of newlines :( while (true) { @@ -34766,6 +35652,9 @@ var ts; case "readonly": tag = parseSimpleTag(start, factory.createJSDocReadonlyTag, tagName, margin, indentText); break; + case "override": + tag = parseSimpleTag(start, factory.createJSDocOverrideTag, tagName, margin, indentText); + break; case "deprecated": hasDeprecatedTag = true; tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText); @@ -34813,7 +35702,10 @@ var ts; return parseTagComments(margin, indentText.slice(margin)); } function parseTagComments(indent, initialMargin) { + var commentsPos = getNodePos(); var comments = []; + var parts = []; + var linkEnd; var state = 0 /* BeginningOfLine */; var previousWhitespace = true; var margin; @@ -34841,8 +35733,9 @@ var ts; indent = 0; break; case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ || !previousWhitespace && state === 2 /* SavingComments */) { - // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace + if (state === 3 /* SavingBackticks */ + || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } @@ -34866,13 +35759,18 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { - pushComment(scanner.getTokenText()); - nextTokenJSDoc(); + var commentEnd = scanner.getStartPos(); + var linkStart = scanner.getTextPos() - 1; + var link = parseJSDocLink(linkStart); + if (link) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos, commentEnd)); + parts.push(link); + comments = []; + linkEnd = scanner.getTextPos(); + } + else { pushComment(scanner.getTokenText()); - nextTokenJSDoc(); } - pushComment(scanner.getTokenText()); break; case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { @@ -34904,11 +35802,46 @@ var ts; } removeLeadingNewlines(comments); removeTrailingWhitespace(comments); - return comments.length === 0 ? undefined : comments.join(""); + if (parts.length) { + if (comments.length) { + parts.push(finishNode(factory.createJSDocText(comments.join("")), linkEnd !== null && linkEnd !== void 0 ? linkEnd : commentsPos)); + } + return createNodeArray(parts, commentsPos, scanner.getTextPos()); + } + else if (comments.length) { + return comments.join(""); + } + } + function isNextJSDocTokenWhitespace() { + var next = nextTokenJSDoc(); + return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + } + function parseJSDocLink(start) { + if (!tryParse(parseJSDocLinkPrefix)) { + return undefined; + } + nextTokenJSDoc(); // start at token after link, then skip any whitespace + skipWhitespace(); + // parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error + var name = ts.tokenIsIdentifierOrKeyword(token()) + ? parseEntityName(/*allowReservedWords*/ true) + : undefined; + var text = []; + while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + text.push(scanner.getTokenText()); + nextTokenJSDoc(); + } + return finishNode(factory.createJSDocLink(name, text.join("")), start, scanner.getTextPos()); + } + function parseJSDocLinkPrefix() { + skipWhitespaceOrAsterisk(); + return token() === 18 /* OpenBraceToken */ + && nextTokenJSDoc() === 59 /* AtToken */ + && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) + && scanner.getTokenValue() === "link"; } function parseUnknownTag(start, tagName, indent, indentText) { - var end = getNodePos(); - return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function addTag(tag) { if (!tag) { @@ -34953,7 +35886,7 @@ var ts; switch (node.kind) { case 145 /* ObjectKeyword */: return true; - case 178 /* ArrayType */: + case 179 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -34965,7 +35898,7 @@ var ts; skipWhitespaceOrAsterisk(); var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed; var indentText = skipWhitespaceOrAsterisk(); - if (isNameFirst) { + if (isNameFirst && !lookAhead(parseJSDocLinkPrefix)) { typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); @@ -34985,12 +35918,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) { + if (child.kind === 330 /* JSDocParameterTag */ || child.kind === 337 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 178 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 179 /* ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -35000,27 +35933,34 @@ var ts; parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = tryParseTypeExpression(); - var end = getNodePos(); - return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseTypeTag(start, tagName, indent, indentText) { if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start, end); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var nameExpression = parseJSDocNameReference(); - var end = getNodePos(); - var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined; - return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start, end); + var isLink = lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenValue() === "link"; }); + var nameExpression = isLink ? undefined : parseJSDocNameReference(); + var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; + return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); } function parseAuthorTag(start, tagName, indent, indentText) { - var comments = parseAuthorNameAndEmail() + (parseTrailingTagComments(start, end, indent, indentText) || ""); - return finishNode(factory.createJSDocAuthorTag(tagName, comments || undefined), start); + var commentStart = getNodePos(); + var textOnly = parseAuthorNameAndEmail(); + var commentEnd = scanner.getStartPos(); + var comments = parseTrailingTagComments(start, commentEnd, indent, indentText); + if (!comments) { + commentEnd = scanner.getStartPos(); + } + var allParts = typeof comments !== "string" + ? createNodeArray(ts.concatenate([finishNode(textOnly, commentStart, commentEnd)], comments), commentStart) // cast away readonly + : textOnly.text + comments; + return finishNode(factory.createJSDocAuthorTag(tagName, allParts), start); } function parseAuthorNameAndEmail() { var comments = []; @@ -35041,17 +35981,15 @@ var ts; comments.push(scanner.getTokenText()); token = nextTokenJSDoc(); } - return comments.join(""); + return factory.createJSDocText(comments.join("")); } function parseImplementsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseAugmentsTag(start, tagName, margin, indentText) { var className = parseExpressionWithTypeArgumentsForAugments(); - var end = getNodePos(); - return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); @@ -35075,20 +36013,17 @@ var ts; return node; } function parseSimpleTag(start, createTag, tagName, margin, indentText) { - var end = getNodePos(); - return finishNode(createTag(tagName, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(createTag(tagName, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseThisTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseEnumTag(start, tagName, margin, indentText) { var typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); - var end = getNodePos(); - return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end); + return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseTypedefTag(start, tagName, indent, indentText) { var _a; @@ -35105,7 +36040,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 329 /* JSDocTypeTag */) { + if (child.kind === 333 /* JSDocTypeTag */) { if (childTypeTag) { parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); var lastError = ts.lastOrUndefined(parseDiagnostics); @@ -35123,7 +36058,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 178 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 179 /* ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -35176,17 +36111,16 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 327 /* JSDocReturnTag */) { + if (tag && tag.kind === 331 /* JSDocReturnTag */) { return tag; } } }); var typeExpression = finishNode(factory.createJSDocSignature(/*typeParameters*/ undefined, parameters, returnTag), start); - var end = getNodePos(); if (!comment) { - comment = parseTrailingTagComments(start, end, indent, indentText); + comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); } - return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end); + return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start); } function escapedTextsEqual(a, b) { while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) { @@ -35211,7 +36145,7 @@ var ts; case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 326 /* JSDocParameterTag */ || child.kind === 333 /* JSDocPropertyTag */) && + if (child && (child.kind === 330 /* JSDocParameterTag */ || child.kind === 337 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -35268,6 +36202,9 @@ var ts; function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); var name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); + if (ts.nodeIsMissing(name)) { + return undefined; + } return finishNode(factory.createTypeParameterDeclaration(name, /*constraint*/ undefined, /*defaultType*/ undefined), typeParameterPos); } function parseTemplateTagTypeParameters() { @@ -35275,7 +36212,10 @@ var ts; var typeParameters = []; do { skipWhitespace(); - typeParameters.push(parseTemplateTagTypeParameter()); + var node = parseTemplateTagTypeParameter(); + if (node !== undefined) { + typeParameters.push(node); + } skipWhitespaceOrAsterisk(); } while (parseOptionalJsdoc(27 /* CommaToken */)); return createNodeArray(typeParameters, pos); @@ -35294,8 +36234,7 @@ var ts; // TODO: Consider only parsing a single type parameter if there is a constraint. var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); - var end = getNodePos(); - return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, end, indent, indentText)), start, end); + return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } function parseOptionalJsdoc(t) { if (token() === t) { @@ -36110,6 +37049,7 @@ var ts; ["es2018", "lib.es2018.d.ts"], ["es2019", "lib.es2019.d.ts"], ["es2020", "lib.es2020.d.ts"], + ["es2021", "lib.es2021.d.ts"], ["esnext", "lib.esnext.d.ts"], // Host only ["dom", "lib.dom.d.ts"], @@ -36149,14 +37089,17 @@ var ts; ["es2020.string", "lib.es2020.string.d.ts"], ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"], ["es2020.intl", "lib.es2020.intl.d.ts"], + ["es2021.promise", "lib.es2021.promise.d.ts"], + ["es2021.string", "lib.es2021.string.d.ts"], + ["es2021.weakref", "lib.es2021.weakref.d.ts"], ["esnext.array", "lib.es2019.array.d.ts"], ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], - ["esnext.string", "lib.esnext.string.d.ts"], - ["esnext.promise", "lib.esnext.promise.d.ts"], - ["esnext.weakref", "lib.esnext.weakref.d.ts"] + ["esnext.string", "lib.es2021.string.d.ts"], + ["esnext.promise", "lib.es2021.promise.d.ts"], + ["esnext.weakref", "lib.es2021.weakref.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -36180,11 +37123,12 @@ var ts; fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval, prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval, dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchFileKind.FixedChunkSizePolling, usefsevents: ts.WatchFileKind.UseFsEvents, usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory, })), category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory, + description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling_UseFsEvents_UseFsEventsOnParentDirectory, }, { name: "watchDirectory", @@ -36192,9 +37136,10 @@ var ts; usefsevents: ts.WatchDirectoryKind.UseFsEvents, fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval, dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling, + fixedchunksizepolling: ts.WatchDirectoryKind.FixedChunkSizePolling, })), category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling, + description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling_FixedChunkSizePolling, }, { name: "fallbackPolling", @@ -36202,9 +37147,10 @@ var ts; fixedinterval: ts.PollingWatchKind.FixedInterval, priorityinterval: ts.PollingWatchKind.PriorityInterval, dynamicpriority: ts.PollingWatchKind.DynamicPriority, + fixedchunksize: ts.PollingWatchKind.FixedChunkSize, })), category: ts.Diagnostics.Advanced_Options, - description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority, + description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority_FixedChunkSize, }, { name: "synchronousWatchDirectory", @@ -36363,6 +37309,7 @@ var ts; es2018: 5 /* ES2018 */, es2019: 6 /* ES2019 */, es2020: 7 /* ES2020 */, + es2021: 8 /* ES2021 */, esnext: 99 /* ESNext */, })), affectsSourceFile: true, @@ -36371,10 +37318,10 @@ var ts; paramType: ts.Diagnostics.VERSION, showInSimplifiedHelpView: true, category: ts.Diagnostics.Basic_Options, - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_ES2021_or_ESNEXT, }; - /* @internal */ - ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsWithoutBuild = [ + // CommandLine only options { name: "all", type: "boolean", @@ -36737,6 +37684,14 @@ var ts; category: ts.Diagnostics.Additional_Checks, description: ts.Diagnostics.Include_undefined_in_index_signature_results }, + { + name: "noImplicitOverride", + type: "boolean", + affectsSemanticDiagnostics: true, + showInSimplifiedHelpView: false, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Ensure_overriding_members_in_derived_classes_are_marked_with_an_override_modifier + }, { name: "noPropertyAccessFromIndexSignature", type: "boolean", @@ -37152,7 +38107,9 @@ var ts; }, description: ts.Diagnostics.List_of_language_service_plugins }, - ]); + ]; + /* @internal */ + ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsWithoutBuild); /* @internal */ ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; }); /* @internal */ @@ -37167,8 +38124,7 @@ var ts; ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) { return ts.hasProperty(option, "transpileOptionValue"); }); - /* @internal */ - ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [ + var commandOptionsOnlyBuild = [ { name: "verbose", shortName: "v", @@ -37196,7 +38152,9 @@ var ts; description: ts.Diagnostics.Delete_the_outputs_of_all_projects, type: "boolean" } - ]); + ]; + /* @internal */ + ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), commandOptionsOnlyBuild); /* @internal */ ts.typeAcquisitionDeclarations = [ { @@ -37250,6 +38208,10 @@ var ts; return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations)); } ts.getOptionsNameMap = getOptionsNameMap; + var compilerOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_only_be_used_with_build, + getOptionsNameMap: getBuildOptionsNameMap + }; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, @@ -37311,6 +38273,10 @@ var ts; return option.name; } function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) { + var _a; + if ((_a = diagnostics.alternateMode) === null || _a === void 0 ? void 0 : _a.getOptionsNameMap().optionsNameMap.has(unknownOption.toLowerCase())) { + return createDiagnostics(diagnostics.alternateMode.diagnostic, unknownOption); + } var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName); return possibleOption ? createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) : @@ -37465,6 +38431,7 @@ var ts; } /*@internal*/ ts.compilerOptionsDidYouMeanDiagnostics = { + alternateMode: compilerOptionsAlternateMode, getOptionsNameMap: getOptionsNameMap, optionDeclarations: ts.optionDeclarations, unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0, @@ -37497,7 +38464,12 @@ var ts; function getBuildOptionsNameMap() { return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts)); } + var buildOptionsAlternateMode = { + diagnostic: ts.Diagnostics.Compiler_option_0_may_not_be_used_with_build, + getOptionsNameMap: getOptionsNameMap + }; var buildOptionsDidYouMeanDiagnostics = { + alternateMode: buildOptionsAlternateMode, getOptionsNameMap: getBuildOptionsNameMap, optionDeclarations: ts.buildOpts, unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0, @@ -37573,7 +38545,7 @@ var ts; function parseConfigFileTextToJson(fileName, jsonText) { var jsonSourceFile = ts.parseJsonText(fileName, jsonText); return { - config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics), + config: convertConfigFileToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics, /*reportOptionsErrors*/ false, /*optionsIterator*/ undefined), error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined }; } @@ -37703,11 +38675,31 @@ var ts; } return _tsconfigRootOptions; } + function convertConfigFileToObject(sourceFile, errors, reportOptionsErrors, optionsIterator) { + var _a; + var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; + var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; + if (rootExpression && rootExpression.kind !== 201 /* ObjectLiteralExpression */) { + 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 + // array is a well-formed configuration object, made into an array element by stray characters. + if (ts.isArrayLiteralExpression(rootExpression)) { + var firstObject = ts.find(rootExpression.elements, ts.isObjectLiteralExpression); + if (firstObject) { + return convertToObjectWorker(sourceFile, firstObject, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } + } + return {}; + } + return convertToObjectWorker(sourceFile, rootExpression, errors, /*returnValue*/ true, knownRootOptions, optionsIterator); + } /** * Convert the json syntax tree into the json value */ function convertToObject(sourceFile, errors) { - return convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); + var _a; + return convertToObjectWorker(sourceFile, (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, errors, /*returnValue*/ true, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); } ts.convertToObject = convertToObject; /** @@ -37716,18 +38708,18 @@ var ts; * Otherwise it just checks the errors and returns undefined */ /*@internal*/ - function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) { - if (!sourceFile.statements.length) { + function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue, knownRootOptions, jsonConversionNotifier) { + if (!rootExpression) { return returnValue ? {} : undefined; } - return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions); + return convertPropertyValueToJson(rootExpression, knownRootOptions); function isRootOptionMap(knownOptions) { return knownRootOptions && knownRootOptions.elementOptions === knownOptions; } function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 288 /* PropertyAssignment */) { + if (element.kind !== 289 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -37821,13 +38813,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 214 /* PrefixUnaryExpression */: + case 215 /* 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 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -37844,7 +38836,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -38481,7 +39473,7 @@ var ts; } } }; - var json = convertToObjectWorker(sourceFile, errors, /*returnValue*/ true, getTsconfigRootOptionsMap(), optionsIterator); + var json = convertConfigFileToObject(sourceFile, errors, /*reportOptionsErrors*/ true, optionsIterator); if (!typeAcquisition) { if (typingOptionstypeAcquisition) { typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ? @@ -39228,13 +40220,24 @@ var ts; * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache) { var traceEnabled = isTraceEnabled(options, host); if (redirectedReference) { options = redirectedReference.commandLine.options; } - var failedLookupLocations = []; - var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var containingDirectory = containingFile ? ts.getDirectoryPath(containingFile) : undefined; + var perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined; + var result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName); + if (result) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile); + if (redirectedReference) + trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + trace(host, ts.Diagnostics.Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1, typeReferenceDirectiveName, containingDirectory); + traceResult(result); + } + return result; + } var typeRoots = getEffectiveTypeRoots(options, host); if (traceEnabled) { if (containingFile === undefined) { @@ -39257,6 +40260,8 @@ var ts; trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); } } + var failedLookupLocations = []; + var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var resolved = primaryLookup(); var primary = true; if (!resolved) { @@ -39267,17 +40272,31 @@ var ts; if (resolved) { var fileName = resolved.fileName, packageId = resolved.packageId; var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); - if (traceEnabled) { - if (packageId) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, ts.packageIdToString(packageId), primary); - } - else { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); - } + resolvedTypeReferenceDirective = { + primary: primary, + resolvedFileName: resolvedFileName, + originalPath: fileName === resolvedFileName ? undefined : fileName, + packageId: packageId, + isExternalLibraryImport: pathContainsNodeModules(fileName), + }; + } + result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; + perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, result); + if (traceEnabled) + traceResult(result); + return result; + function traceResult(result) { + var _a; + if (!((_a = result.resolvedTypeReferenceDirective) === null || _a === void 0 ? void 0 : _a.resolvedFileName)) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + else if (result.resolvedTypeReferenceDirective.packageId) { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, ts.packageIdToString(result.resolvedTypeReferenceDirective.packageId), result.resolvedTypeReferenceDirective.primary); + } + else { + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } - return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { // Check primary library paths if (typeRoots && typeRoots.length) { @@ -39307,20 +40326,16 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } - var result = void 0; + var result_4; if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) { var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined); - result = searchResult && searchResult.value; + result_4 = searchResult && searchResult.value; } else { var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path; - result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); - } - var resolvedFile = resolvedTypeScriptOnly(result); - if (!resolvedFile && traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + result_4 = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - return resolvedFile; + return resolvedTypeScriptOnly(result_4); } else { if (traceEnabled) { @@ -39375,22 +40390,21 @@ var ts; return result; } ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames; - function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) { - return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName); - } - ts.createModuleResolutionCache = createModuleResolutionCache; /*@internal*/ function createCacheWithRedirects(options) { var ownMap = new ts.Map(); var redirectsMap = new ts.Map(); return { - ownMap: ownMap, + getOwnMap: getOwnMap, redirectsMap: redirectsMap, getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects, clear: clear, setOwnOptions: setOwnOptions, setOwnMap: setOwnMap }; + function getOwnMap() { + return ownMap; + } function setOwnOptions(newOptions) { options = newOptions; } @@ -39416,26 +40430,88 @@ var ts; } } ts.createCacheWithRedirects = createCacheWithRedirects; - /*@internal*/ - function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) { - return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap }; + function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { + var cache; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear }; + function getPackageJsonInfo(packageJsonPath) { + return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); + } + function setPackageJsonInfo(packageJsonPath, info) { + (cache || (cache = new ts.Map())).set(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info); + } + function clear() { + cache = undefined; + } + } + function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { + var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + var result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); + } + return result; + } + function updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + if (!options.configFile) + return; + if (directoryToModuleNameMap.redirectsMap.size === 0) { + // The own map will be for projectCompilerOptions + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0); + ts.Debug.assert(directoryToModuleNameMap.getOwnMap().size === 0); + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.getOwnMap().size === 0); + directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.getOwnMap()); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.getOwnMap()); + } + else { + // Set correct own map + ts.Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0); + var ref = { + sourceFile: options.configFile, + commandLine: { options: options } + }; + directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); + } + directoryToModuleNameMap.setOwnOptions(options); + moduleNameToDirectoryMap === null || moduleNameToDirectoryMap === void 0 ? void 0 : moduleNameToDirectoryMap.setOwnOptions(options); + } + function createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap) { + return { + getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, + clear: clear, + update: update, + }; + function clear() { + directoryToModuleNameMap.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap); + } function getOrCreateCacheForDirectory(directoryName, redirectedReference) { var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName); return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return new ts.Map(); }); } + } + function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { + var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options)); + var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); + return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, + clear: clear, + update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } }); + function clear() { + preDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + packageJsonInfoCache.clear(); + } + function update(options) { + updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); + } function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); } - function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { - var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); - var result = cache.get(key); - if (!result) { - result = create(); - cache.set(key, result); - } - return result; - } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); return { get: get, set: set }; @@ -39502,7 +40578,17 @@ var ts; } } } - ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps; + ts.createModuleResolutionCache = createModuleResolutionCache; + function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { + var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); + return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + function clear() { + preDirectoryResolutionCache.clear(); + packageJsonInfoCache.clear(); + } + } + ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache) { var containingDirectory = ts.getDirectoryPath(containingFile); var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); @@ -39780,7 +40866,7 @@ var ts; var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; - var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; 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) { @@ -39840,7 +40926,7 @@ var ts; } var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state); if (resolvedFromFile) { - var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined; + var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile.path) : undefined; var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined; return withPackageId(packageInfo, resolvedFromFile); } @@ -39873,8 +40959,9 @@ var ts; * For `/node_modules/@types/foo/bar/index.d.ts` this is packageDirectory: "@types/foo" * For `/node_modules/foo/bar/index.d.ts` this is packageDirectory: "foo" */ + /* @internal */ function parseNodeModuleFromPath(resolved) { - var path = ts.normalizePath(resolved.path); + var path = ts.normalizePath(resolved); var idx = path.lastIndexOf(ts.nodeModulesPathPart); if (idx === -1) { return undefined; @@ -39886,6 +40973,7 @@ var ts; } return path.slice(0, indexAfterPackageName); } + ts.parseNodeModuleFromPath = parseNodeModuleFromPath; function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) { var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1); return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex; @@ -39969,21 +41057,43 @@ var ts; return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths)); } function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) { + var _a, _b, _c; var host = state.host, traceEnabled = state.traceEnabled; - var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host); var packageJsonPath = ts.combinePaths(packageDirectory, "package.json"); + if (onlyRecordFailures) { + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + var existing = (_a = state.packageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfo(packageJsonPath); + if (existing !== undefined) { + if (typeof existing !== "boolean") { + if (traceEnabled) + trace(host, ts.Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath); + return existing; + } + else { + if (existing && traceEnabled) + trace(host, ts.Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath); + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + } + var directoryExists = ts.directoryProbablyExists(packageDirectory, host); if (directoryExists && host.fileExists(packageJsonPath)) { var packageJsonContent = ts.readJson(packageJsonPath, host); if (traceEnabled) { trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state); - return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + var result = { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths }; + (_b = state.packageJsonInfoCache) === null || _b === void 0 ? void 0 : _b.setPackageJsonInfo(packageJsonPath, result); + return result; } else { if (directoryExists && traceEnabled) { trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + (_c = state.packageJsonInfoCache) === null || _c === void 0 ? void 0 : _c.setPackageJsonInfo(packageJsonPath, directoryExists); // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results state.failedLookupLocations.push(packageJsonPath); } @@ -40232,7 +41342,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 }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache }; var containingDirectory = ts.getDirectoryPath(containingFile); var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath @@ -40273,13 +41383,13 @@ var ts; * This is the minumum code needed to expose that functionality; the rest is in the host. */ /* @internal */ - function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) { + function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache, packageJsonInfoCache) { var traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { 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 }; + var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); } @@ -40325,26 +41435,26 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportDeclaration */: + case 261 /* 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 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 268 /* NamedExports */) { + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 269 /* NamedExports */) { var state = 0 /* NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; @@ -40360,7 +41470,7 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 257 /* ModuleBlock */: { + case 258 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); @@ -40382,7 +41492,7 @@ var ts; }); return state_1; } - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return getModuleInstanceState(node, visited); case 78 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -40500,6 +41610,7 @@ var ts; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) * If so, the node _must_ be in the current file (as that's the only way anything could have traversed to it to yield it as the error node) @@ -40582,7 +41693,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 === 266 /* ExportAssignment */) { + if (node.kind === 267 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -40591,7 +41702,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 159 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -40600,11 +41711,9 @@ var ts; if (ts.isSignedNumericLiteral(nameExpression)) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } - ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); - return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); - } - if (ts.isWellKnownSymbolSyntactically(name)) { - return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + else { + ts.Debug.fail("Only computed properties with literal names have declaration names"); + } } if (ts.isPrivateIdentifier(name)) { // containingClass exists because private names only allowed inside classes @@ -40619,36 +41728,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 166 /* Constructor */: + case 167 /* Constructor */: return "__constructor" /* Constructor */; - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: + case 175 /* FunctionType */: + case 170 /* CallSignature */: + case 315 /* JSDocSignature */: return "__call" /* Call */; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 176 /* ConstructorType */: + case 171 /* ConstructSignature */: return "__new" /* New */; - case 171 /* IndexSignature */: + case 172 /* IndexSignature */: return "__index" /* Index */; - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 297 /* SourceFile */: + case 298 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 308 /* JSDocFunctionType */: + case 309 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 160 /* Parameter */: + case 161 /* 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 === 308 /* 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 === 309 /* 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; @@ -40748,7 +41857,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 === 266 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 267 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -40787,7 +41896,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 270 /* ExportSpecifier */ || (node.kind === 260 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 271 /* ExportSpecifier */ || (node.kind === 261 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -40876,7 +41985,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 !== 209 /* ArrowFunction */) { + if (node.kind !== 210 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -40909,7 +42018,7 @@ var ts; } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 167 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 252 /* FunctionDeclaration */ || node.kind === 209 /* FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -40924,13 +42033,14 @@ var ts; node.flags |= 512 /* HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 298 /* SourceFile */) { node.flags |= emitFlags; + node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 166 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */))) { + if (node.kind === 167 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 252 /* FunctionDeclaration */ || node.kind === 209 /* FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -40957,8 +42067,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 251 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 252 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 252 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -40981,59 +42091,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 232 /* FirstStatement */ && node.kind <= 248 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 233 /* FirstStatement */ && node.kind <= 249 /* LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 236 /* WhileStatement */: + case 237 /* WhileStatement */: bindWhileStatement(node); break; - case 235 /* DoStatement */: + case 236 /* DoStatement */: bindDoStatement(node); break; - case 237 /* ForStatement */: + case 238 /* ForStatement */: bindForStatement(node); break; - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 234 /* IfStatement */: + case 235 /* IfStatement */: bindIfStatement(node); break; - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: + case 243 /* ReturnStatement */: + case 247 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 242 /* BreakStatement */: + case 241 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 247 /* TryStatement */: + case 248 /* TryStatement */: bindTryStatement(node); break; - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: bindSwitchStatement(node); break; - case 258 /* CaseBlock */: + case 259 /* CaseBlock */: bindCaseBlock(node); break; - case 284 /* CaseClause */: + case 285 /* CaseClause */: bindCaseClause(node); break; - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: bindExpressionStatement(node); break; - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: bindLabeledStatement(node); break; - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -41043,47 +42153,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 210 /* DeleteExpression */: + case 211 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 203 /* CallExpression */: + case 204 /* CallExpression */: bindCallExpressionFlow(node); break; - case 225 /* NonNullExpression */: + case 226 /* NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 335 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: + case 329 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 297 /* SourceFile */: { + case 298 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 231 /* Block */: + case 258 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 198 /* BindingElement */: + case 199 /* BindingElement */: bindBindingElementFlow(node); break; - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: - case 288 /* PropertyAssignment */: - case 220 /* SpreadElement */: + case 201 /* ObjectLiteralExpression */: + case 200 /* ArrayLiteralExpression */: + case 289 /* PropertyAssignment */: + case 221 /* 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; @@ -41100,29 +42210,29 @@ var ts; case 78 /* Identifier */: case 79 /* PrivateIdentifier */: case 107 /* ThisKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: return containsNarrowableReference(expr); - case 203 /* CallExpression */: + case 204 /* CallExpression */: return hasNarrowableArgument(expr); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 208 /* ParenthesizedExpression */: + case 226 /* NonNullExpression */: return isNarrowingExpression(expr.expression); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 211 /* TypeOfExpression */: + case 212 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 78 /* Identifier */ || expr.kind === 79 /* PrivateIdentifier */ || expr.kind === 107 /* ThisKeyword */ || expr.kind === 105 /* SuperKeyword */ || - (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) || - ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || - ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); + return ts.isDottedName(expr) + || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) + || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } function containsNarrowableReference(expr) { return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression); @@ -41136,7 +42246,7 @@ var ts; } } } - if (expr.expression.kind === 201 /* PropertyAccessExpression */ && + if (expr.expression.kind === 202 /* PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -41172,9 +42282,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -41250,26 +42360,26 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 235 /* IfStatement */: + case 237 /* WhileStatement */: + case 236 /* DoStatement */: return parent.expression === node; - case 237 /* ForStatement */: - case 217 /* ConditionalExpression */: + case 238 /* ForStatement */: + case 218 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 207 /* ParenthesizedExpression */) { + if (node.kind === 208 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 214 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 215 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + return node.kind === 217 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */); } @@ -41316,7 +42426,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 245 /* LabeledStatement */) { + while (label && node.parent.kind === 246 /* LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -41367,12 +42477,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 239 /* ForOfStatement */) { + if (node.kind === 240 /* ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 250 /* VariableDeclarationList */) { + if (node.initializer.kind !== 251 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -41394,7 +42504,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 242 /* ReturnStatement */) { + if (node.kind === 243 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -41411,7 +42521,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 241 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 242 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -41516,7 +42626,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 285 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 286 /* 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. @@ -41564,9 +42674,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or LHS of comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 204 /* CallExpression */) { var call = node; - if (ts.isDottedName(call.expression) && call.expression.kind !== 105 /* SuperKeyword */) { + if (call.expression.kind !== 105 /* SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -41590,7 +42700,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { + if (node.kind === 217 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -41601,10 +42711,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); } - else if (node.kind === 199 /* ArrayLiteralExpression */) { + else if (node.kind === 200 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 220 /* SpreadElement */) { + if (e.kind === 221 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -41612,16 +42722,16 @@ var ts; } } } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 201 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 288 /* PropertyAssignment */) { + if (p.kind === 289 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 289 /* ShorthandPropertyAssignment */) { + else if (p.kind === 290 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 290 /* SpreadAssignment */) { + else if (p.kind === 291 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -41686,128 +42796,102 @@ var ts; } bindAssignmentTargetFlow(node.left); } - var BindBinaryExpressionFlowState; - (function (BindBinaryExpressionFlowState) { - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindThenBindChildren"] = 0] = "BindThenBindChildren"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["MaybeBindLeft"] = 1] = "MaybeBindLeft"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindToken"] = 2] = "BindToken"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["BindRight"] = 3] = "BindRight"; - BindBinaryExpressionFlowState[BindBinaryExpressionFlowState["FinishBind"] = 4] = "FinishBind"; - })(BindBinaryExpressionFlowState || (BindBinaryExpressionFlowState = {})); - function bindBinaryExpressionFlow(node) { - var workStacks = { - expr: [node], - state: [1 /* MaybeBindLeft */], - inStrictMode: [undefined], - parent: [undefined], - }; - var stackIndex = 0; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* BindThenBindChildren */: { - // This state is used only when recuring, to emulate the work that `bind` does before - // reaching `bindChildren`. A normal call to `bindBinaryExpressionFlow` will already have done this work. - ts.setParent(node, parent); - var saveInStrictMode = inStrictMode; - bindWorker(node); - var saveParent = parent; - parent = node; - advanceState(1 /* MaybeBindLeft */, saveInStrictMode, saveParent); - break; - } - case 1 /* MaybeBindLeft */: { - var operator = node.operatorToken.kind; - // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions - // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too - // For now, though, since the common cases are chained `+`, leaving it recursive is fine - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */ || - ts.isLogicalOrCoalescingAssignmentOperator(operator)) { - if (isTopLevelLogicalExpression(node)) { - var postExpressionLabel = createBranchLabel(); - bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); - currentFlow = finishFlowLabel(postExpressionLabel); - } - else { - bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); - } - completeNode(); - } - else { - advanceState(2 /* BindToken */); - maybeBind(node.left); - } - break; + function createBindBinaryExpressionFlow() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + // Emulate the work that `bind` does before reaching `bindChildren`. A normal call to + // `bindBinaryExpressionFlow` will already have done this work. + ts.setParent(node, parent); + var saveInStrictMode = inStrictMode; + bindWorker(node); + var saveParent = parent; + parent = node; + state.skip = false; + state.inStrictModeStack[state.stackIndex] = saveInStrictMode; + state.parentStack[state.stackIndex] = saveParent; + } + else { + state = { + stackIndex: 0, + skip: false, + inStrictModeStack: [undefined], + parentStack: [undefined] + }; + } + // TODO: bindLogicalExpression is recursive - if we want to handle deeply nested `&&` expressions + // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too + // For now, though, since the common cases are chained `+`, leaving it recursive is fine + var operator = node.operatorToken.kind; + if (operator === 55 /* AmpersandAmpersandToken */ || + operator === 56 /* BarBarToken */ || + operator === 60 /* QuestionQuestionToken */ || + ts.isLogicalOrCoalescingAssignmentOperator(operator)) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); } - case 2 /* BindToken */: { - if (node.operatorToken.kind === 27 /* CommaToken */) { - maybeBindExpressionFlowIfCall(node.left); - } - advanceState(3 /* BindRight */); - maybeBind(node.operatorToken); - break; + else { + bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget); } - case 3 /* BindRight */: { - advanceState(4 /* FinishBind */); - maybeBind(node.right); - break; + state.skip = true; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeBind(left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + if (operatorToken.kind === 27 /* CommaToken */) { + maybeBindExpressionFlowIfCall(node.left); } - case 4 /* FinishBind */: { - var operator = node.operatorToken.kind; - if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { - bindAssignmentTargetFlow(node.left); - if (operator === 62 /* EqualsToken */ && node.left.kind === 202 /* ElementAccessExpression */) { - var elementAccess = node.left; - if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); - } + bind(operatorToken); + } + } + function onRight(right, state, _node) { + if (!state.skip) { + return maybeBind(right); + } + } + function onExit(node, state) { + if (!state.skip) { + var operator = node.operatorToken.kind; + if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { + bindAssignmentTargetFlow(node.left); + if (operator === 62 /* EqualsToken */ && node.left.kind === 203 /* ElementAccessExpression */) { + var elementAccess = node.left; + if (isNarrowableOperand(elementAccess.expression)) { + currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); } } - completeNode(); - break; } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow"); - } - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeBind` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeBind` during a state's execution. - */ - function advanceState(state, isInStrictMode, parent) { - workStacks.state[stackIndex] = state; - if (isInStrictMode !== undefined) { - workStacks.inStrictMode[stackIndex] = isInStrictMode; } - if (parent !== undefined) { - workStacks.parent[stackIndex] = parent; + var savedInStrictMode = state.inStrictModeStack[state.stackIndex]; + var savedParent = state.parentStack[state.stackIndex]; + if (savedInStrictMode !== undefined) { + inStrictMode = savedInStrictMode; } - } - function completeNode() { - if (workStacks.inStrictMode[stackIndex] !== undefined) { - inStrictMode = workStacks.inStrictMode[stackIndex]; - parent = workStacks.parent[stackIndex]; + if (savedParent !== undefined) { + parent = savedParent; } - stackIndex--; + state.skip = false; + state.stackIndex--; } - /** - * If `node` is a BinaryExpression, adds it to the local work stack, otherwise recursively binds it - */ function maybeBind(node) { if (node && ts.isBinaryExpression(node) && !ts.isDestructuringAssignment(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* BindThenBindChildren */; - workStacks.inStrictMode[stackIndex] = undefined; - workStacks.parent[stackIndex] = undefined; - } - else { - bind(node); + return node; } + bind(node); } } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 202 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -41864,7 +42948,7 @@ var ts; } function bindJSDocTypeAlias(node) { ts.setParent(node.tagName, node); - if (node.kind !== 325 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 329 /* JSDocEnumTag */ && node.fullName) { ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); } @@ -41872,7 +42956,7 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 165 /* MethodDeclaration */) { + if (host && host.kind !== 166 /* MethodDeclaration */) { addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } } @@ -41885,15 +42969,15 @@ var ts; } function bindOptionalChainRest(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 203 /* CallExpression */: + case 204 /* CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -41958,7 +43042,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 === 208 /* FunctionExpression */ || expr.kind === 209 /* ArrowFunction */) { + if (expr.kind === 209 /* FunctionExpression */ || expr.kind === 210 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -41970,7 +43054,7 @@ var ts; } } } - if (node.expression.kind === 201 /* PropertyAccessExpression */) { + if (node.expression.kind === 202 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); @@ -41979,54 +43063,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 281 /* JsxAttributes */: + case 222 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 256 /* EnumDeclaration */: + case 201 /* ObjectLiteralExpression */: + case 178 /* TypeLiteral */: + case 314 /* JSDocTypeLiteral */: + case 282 /* JsxAttributes */: return 1 /* IsContainer */; - case 253 /* InterfaceDeclaration */: + case 254 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 257 /* ModuleDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 191 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 297 /* SourceFile */: + case 298 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 169 /* CallSignature */: - case 313 /* JSDocSignature */: - case 308 /* JSDocFunctionType */: - case 174 /* FunctionType */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: - case 175 /* ConstructorType */: + case 167 /* Constructor */: + case 252 /* FunctionDeclaration */: + case 165 /* MethodSignature */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 170 /* CallSignature */: + case 315 /* JSDocSignature */: + case 309 /* JSDocFunctionType */: + case 175 /* FunctionType */: + case 171 /* ConstructSignature */: + case 172 /* IndexSignature */: + case 176 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 257 /* ModuleBlock */: + case 258 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 287 /* CatchClause */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 258 /* CaseBlock */: + case 288 /* CatchClause */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 259 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 230 /* Block */: + case 231 /* 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 @@ -42059,45 +43143,45 @@ 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 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 297 /* SourceFile */: + case 298 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 253 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 200 /* ObjectLiteralExpression */: - case 253 /* InterfaceDeclaration */: - case 281 /* JsxAttributes */: + case 178 /* TypeLiteral */: + case 314 /* JSDocTypeLiteral */: + case 201 /* ObjectLiteralExpression */: + case 254 /* InterfaceDeclaration */: + case 282 /* 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 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 313 /* JSDocSignature */: - case 171 /* IndexSignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 308 /* JSDocFunctionType */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 254 /* TypeAliasDeclaration */: - case 190 /* MappedType */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 315 /* JSDocSignature */: + case 172 /* IndexSignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 309 /* JSDocFunctionType */: + case 335 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: + case 255 /* TypeAliasDeclaration */: + case 191 /* MappedType */: // 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 @@ -42198,7 +43282,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 === 290 /* SpreadAssignment */ || prop.name.kind !== 78 /* Identifier */) { + if (prop.kind === 291 /* SpreadAssignment */ || prop.name.kind !== 78 /* Identifier */) { continue; } var identifier = prop.name; @@ -42210,7 +43294,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 === 288 /* PropertyAssignment */ || prop.kind === 289 /* ShorthandPropertyAssignment */ || prop.kind === 165 /* MethodDeclaration */ + var currentKind = prop.kind === 289 /* PropertyAssignment */ || prop.kind === 290 /* ShorthandPropertyAssignment */ || prop.kind === 166 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -42242,10 +43326,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 297 /* SourceFile */: + case 298 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -42270,9 +43354,9 @@ var ts; var saveCurrentFlow = currentFlow; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; - var host = ts.getJSDocHost(typeAlias); - container = (host && ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); })) || file; - blockScopeContainer = (host && ts.getEnclosingBlockScopeContainer(host)) || file; + var host = typeAlias.parent.parent; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); @@ -42444,8 +43528,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 297 /* SourceFile */ && - blockScopeContainer.kind !== 256 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 298 /* SourceFile */ && + blockScopeContainer.kind !== 257 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -42540,7 +43624,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 > 156 /* LastToken */) { + if (node.kind > 157 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -42616,22 +43700,23 @@ var ts; } // falls through case 107 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 289 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 290 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 157 /* QualifiedName */: - if (currentFlow && parent.kind === 176 /* TypeQuery */) { + case 158 /* QualifiedName */: + if (currentFlow && parent.kind === 177 /* TypeQuery */) { node.flowNode = currentFlow; } break; + case 227 /* MetaProperty */: case 105 /* SuperKeyword */: node.flowNode = currentFlow; break; case 79 /* PrivateIdentifier */: return checkPrivateIdentifier(node); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -42646,7 +43731,7 @@ var ts; declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -42682,78 +43767,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 287 /* CatchClause */: + case 288 /* CatchClause */: return checkStrictModeCatchClause(node); - case 210 /* DeleteExpression */: + case 211 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 243 /* WithStatement */: + case 244 /* WithStatement */: return checkStrictModeWithStatement(node); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 187 /* ThisType */: + case 188 /* ThisType */: seenThisKeyword = true; return; - case 172 /* TypePredicate */: + case 173 /* TypePredicate */: break; // Binding the children will handle everything - case 159 /* TypeParameter */: + case 160 /* TypeParameter */: return bindTypeParameter(node); - case 160 /* Parameter */: + case 161 /* Parameter */: return bindParameter(node); - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 198 /* BindingElement */: + case 199 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: return bindPropertyWorker(node); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 289 /* PropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 291 /* EnumMember */: + case 292 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 172 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 166 /* MethodDeclaration */: + case 165 /* 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 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 166 /* Constructor */: + case 167 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 167 /* GetAccessor */: + case 168 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 168 /* SetAccessor */: + case 169 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 174 /* FunctionType */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: - case 175 /* ConstructorType */: + case 175 /* FunctionType */: + case 309 /* JSDocFunctionType */: + case 315 /* JSDocSignature */: + case 176 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 190 /* MappedType */: + case 178 /* TypeLiteral */: + case 314 /* JSDocTypeLiteral */: + case 191 /* MappedType */: return bindAnonymousTypeWorker(node); - case 319 /* JSDocClassTag */: + case 322 /* JSDocClassTag */: return bindJSDocClassTag(node); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return bindFunctionExpression(node); - case 203 /* CallExpression */: + case 204 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -42772,65 +43857,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 253 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 254 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 254 /* TypeAliasDeclaration */: + case 255 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 281 /* JsxAttributes */: + case 282 /* JsxAttributes */: return bindJsxAttributes(node); - case 280 /* JsxAttribute */: + case 281 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 261 /* ImportEqualsDeclaration */: + case 264 /* NamespaceImport */: + case 266 /* ImportSpecifier */: + case 271 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 259 /* NamespaceExportDeclaration */: + case 260 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 262 /* ImportClause */: + case 263 /* ImportClause */: return bindImportClause(node); - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: return bindExportDeclaration(node); - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return bindExportAssignment(node); - case 297 /* SourceFile */: + case 298 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 230 /* Block */: + case 231 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 257 /* ModuleBlock */: + case 258 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 326 /* JSDocParameterTag */: - if (node.parent.kind === 313 /* JSDocSignature */) { + case 330 /* JSDocParameterTag */: + if (node.parent.kind === 315 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 312 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 314 /* JSDocTypeLiteral */) { break; } // falls through - case 333 /* JSDocPropertyTag */: + case 337 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 307 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 308 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 335 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: + case 329 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -42858,8 +43943,8 @@ var ts; } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { - // Export assignment in some sort of block construct - bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); + // Incorrect export assignment in some sort of block construct + bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) @@ -42993,8 +44078,8 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { @@ -43016,11 +44101,11 @@ var ts; addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* Constructor */: + case 164 /* PropertyDeclaration */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -43032,7 +44117,7 @@ var ts; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); } break; - case 297 /* SourceFile */: + case 298 /* 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; @@ -43061,7 +44146,7 @@ var ts; if (node.expression.kind === 107 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 297 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 298 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -43101,7 +44186,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 297 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 298 /* SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -43210,8 +44295,8 @@ var ts; } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 297 /* SourceFile */ - : propertyAccess.parent.parent.kind === 297 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 298 /* SourceFile */ + : propertyAccess.parent.parent.kind === 298 /* SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -43290,7 +44375,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 252 /* ClassDeclaration */) { + if (node.kind === 253 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -43332,7 +44417,7 @@ var ts; checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true) && !ts.getJSDocTypeTag(node)) { + if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node) && !ts.getJSDocTypeTag(node)) { declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { @@ -43356,7 +44441,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 326 /* JSDocParameterTag */ && container.kind !== 313 /* JSDocSignature */) { + if (node.kind === 330 /* JSDocParameterTag */ && container.kind !== 315 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { @@ -43433,7 +44518,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 185 /* InferType */) { + else if (node.parent.kind === 186 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -43461,11 +44546,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 231 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 232 /* EmptyStatement */) || // report error on class declarations - node.kind === 252 /* ClassDeclaration */ || + node.kind === 253 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 256 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 257 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -43509,12 +44594,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: return true; - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: return ts.hasSyntacticModifier(s, 2048 /* Const */); default: return false; @@ -43714,7 +44799,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 === 176 /* TypeQuery */) { + if (d.type && d.type.kind === 177 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -43941,6 +45026,7 @@ var ts; DeclarationMeaning[DeclarationMeaning["SetAccessor"] = 2] = "SetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignment"] = 4] = "PropertyAssignment"; DeclarationMeaning[DeclarationMeaning["Method"] = 8] = "Method"; + DeclarationMeaning[DeclarationMeaning["PrivateStatic"] = 16] = "PrivateStatic"; DeclarationMeaning[DeclarationMeaning["GetOrSetAccessor"] = 3] = "GetOrSetAccessor"; DeclarationMeaning[DeclarationMeaning["PropertyAssignmentOrMethod"] = 12] = "PropertyAssignmentOrMethod"; })(DeclarationMeaning || (DeclarationMeaning = {})); @@ -44032,12 +45118,12 @@ var ts; var instantiationCount = 0; var instantiationDepth = 0; var currentNode; - var typeCatalog = []; // NB: id is index + 1 var emptySymbols = ts.createSymbolTable(); var arrayVariances = [1 /* Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions); var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks"); var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes"); @@ -44046,7 +45132,8 @@ var ts; var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny"); var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 16384 /* FreshLiteral */; + var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); @@ -44069,7 +45156,6 @@ var ts; getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, - getTypeCatalog: function () { return typeCatalog; }, getTypeCount: function () { return typeCount; }, getInstantiationCount: function () { return totalInstantiationCount; }, getRelationCacheSizes: function () { return ({ @@ -44233,6 +45319,7 @@ var ts; return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, + getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); @@ -44276,6 +45363,7 @@ var ts; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); }, + tryFindAmbientModule: function (moduleName) { return tryFindAmbientModule(moduleName, /*withAugmentations*/ true); }, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { // we deliberately exclude augmentations // since we are only interested in declarations of the module itself @@ -44394,6 +45482,7 @@ var ts; var templateLiteralTypes = new ts.Map(); var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); + var subtypeReductionCache = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var unknownSymbol = createSymbol(4 /* Property */, "unknown"); @@ -44402,14 +45491,14 @@ var ts; var autoType = createIntrinsicType(1 /* Any */, "any"); var wildcardType = createIntrinsicType(1 /* Any */, "any"); var errorType = createIntrinsicType(1 /* Any */, "error"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 524288 /* ContainsWideningType */); + var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 131072 /* ContainsWideningType */); var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 524288 /* ContainsWideningType */); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 131072 /* ContainsWideningType */); var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 524288 /* ContainsWideningType */); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 131072 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); var numberType = createIntrinsicType(8 /* Number */, "number"); var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); @@ -44435,7 +45524,7 @@ var ts; var voidType = createIntrinsicType(16384 /* Void */, "void"); var neverType = createIntrinsicType(131072 /* Never */, "never"); var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 2097152 /* NonInferrableType */); + var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 524288 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); @@ -44447,7 +45536,7 @@ var ts; var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; + emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44456,7 +45545,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 2097152 /* NonInferrableType */; + anyFunctionType.objectFlags |= 524288 /* NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -44536,6 +45625,7 @@ var ts; // This allows users to just specify library files they want to used through --lib // and they will not get an error from not having unrelated library files var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolConstructorTypeSymbol; var deferredGlobalESSymbolType; var deferredGlobalTypedPropertyDescriptorType; var deferredGlobalPromiseType; @@ -44587,7 +45677,7 @@ var ts; var flowNodePostSuper = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; - var potentialWeakMapCollisions = []; + var potentialWeakMapSetCollisions = []; var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var suggestionDiagnostics = ts.createDiagnosticCollection(); @@ -44866,7 +45956,7 @@ var ts; // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. if (target !== globalThisSymbol) { - error(ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations && ts.getNameOfDeclaration(source.declarations[0]), ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } } else { // error @@ -44900,9 +45990,11 @@ var ts; } return target; function addDuplicateLocations(locs, symbol) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.pushIfUnique(locs, decl); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.pushIfUnique(locs, decl); + } } } } @@ -44948,9 +46040,9 @@ var ts; }); } function mergeModuleAugmentation(moduleName) { - var _a, _b; + var _a, _b, _c; var moduleAugmentation = moduleName.parent; - if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) { + if (((_a = moduleAugmentation.symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. // its symbol already has accumulated information for all declarations // so we need to add it just once - do the work only for first declaration @@ -44987,11 +46079,11 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_a = mainModule_1.exports) === null || _a === void 0 ? void 0 : _a.get("__export" /* ExportStar */)) && ((_b = moduleAugmentation.symbol.exports) === null || _b === void 0 ? void 0 : _b.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); - for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) { - var _d = _c[_i], key = _d[0], value = _d[1]; + for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { + var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { mergeSymbol(resolvedExports.get(key), value); } @@ -45032,7 +46124,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 298 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -45091,17 +46183,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 === 198 /* BindingElement */) { + if (declaration.kind === 199 /* 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, 198 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 199 /* 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, 249 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 250 /* VariableDeclaration */), usage); } - else if (declaration.kind === 249 /* VariableDeclaration */) { + else if (declaration.kind === 250 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -45115,7 +46207,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 */ && !!compilerOptions.useDefineForClassFields + return !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -45131,19 +46223,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 === 270 /* ExportSpecifier */ || (usage.parent.kind === 266 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 271 /* ExportSpecifier */ || (usage.parent.kind === 267 /* 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 === 266 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 267 /* ExportAssignment */ && usage.isExportEquals) { return true; } if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + if (compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -45158,9 +46250,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 232 /* VariableStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 233 /* VariableStatement */: + case 238 /* ForStatement */: + case 240 /* 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)) { @@ -45181,16 +46273,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 163 /* PropertyDeclaration */ && + current.parent.kind === 164 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasSyntacticModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 165 /* MethodDeclaration */) { + if (declaration.kind === 166 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 164 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -45212,19 +46304,19 @@ var ts; return "quit"; } switch (node.kind) { - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return true; - case 163 /* PropertyDeclaration */: + case 164 /* 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 230 /* Block */: + case 231 /* Block */: switch (node.parent.kind) { - case 167 /* GetAccessor */: - case 165 /* MethodDeclaration */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 166 /* MethodDeclaration */: + case 169 /* SetAccessor */: return true; default: return false; @@ -45239,7 +46331,11 @@ var ts; function useOuterVariableScopeInParameter(result, location, lastLocation) { var target = ts.getEmitScriptTarget(compilerOptions); var functionLocation = location; - if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + if (ts.isParameter(lastLocation) + && functionLocation.body + && result.valueDeclaration + && result.valueDeclaration.pos >= functionLocation.body.pos + && result.valueDeclaration.end <= functionLocation.body.end) { // check for several cases where we introduce temporaries that require moving the name/initializer of the parameter to the body // - static field in a class expression // - optional chaining pre-es2020 @@ -45260,21 +46356,21 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 166 /* Constructor */: + case 210 /* ArrowFunction */: + case 209 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 167 /* Constructor */: // do not descend into these return false; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 288 /* PropertyAssignment */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 289 /* PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !compilerOptions.useDefineForClassFields; + return target < 99 /* ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: @@ -45303,6 +46399,7 @@ var ts; return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage); } function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) { + var _a; var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location var result; var lastLocation; @@ -45325,12 +46422,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 !== 311 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 312 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 160 /* Parameter */ || - lastLocation.kind === 159 /* TypeParameter */ + lastLocation.kind === 161 /* Parameter */ || + lastLocation.kind === 160 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -45345,13 +46442,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 === 160 /* Parameter */ || + lastLocation.kind === 161 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 184 /* ConditionalType */) { + else if (location.kind === 185 /* 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; @@ -45366,14 +46463,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 297 /* SourceFile */: + case 298 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports || emptySymbols; - if (location.kind === 297 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 298 /* 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 */)) { @@ -45397,13 +46494,13 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 270 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 269 /* NamespaceExport */))) { + (ts.getDeclarationOfKind(moduleExport, 271 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 270 /* 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 && !result.declarations.some(ts.isJSDocTypeAlias)) { + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_a = result.declarations) === null || _a === void 0 ? void 0 : _a.some(ts.isJSDocTypeAlias))) { result = undefined; } else { @@ -45411,12 +46508,12 @@ var ts; } } break; - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 163 /* PropertyDeclaration */: + case 164 /* 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 @@ -45433,9 +46530,9 @@ var ts; } } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* 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! @@ -45454,7 +46551,7 @@ var ts; } break loop; } - if (location.kind === 221 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 222 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -45462,7 +46559,7 @@ var ts; } } break; - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 93 /* ExtendsKeyword */) { var container = location.parent.parent; @@ -45482,9 +46579,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 253 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 254 /* 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); @@ -45492,24 +46589,24 @@ var ts; } } break; - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: + case 166 /* MethodDeclaration */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 252 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 208 /* FunctionExpression */: + case 209 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -45522,7 +46619,7 @@ var ts; } } break; - case 161 /* Decorator */: + case 162 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -45531,7 +46628,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 === 160 /* Parameter */) { + if (location.parent && location.parent.kind === 161 /* Parameter */) { location = location.parent; } // @@ -45546,20 +46643,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 === 252 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 253 /* ClassDeclaration */)) { location = location.parent; } break; - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 335 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: + case 329 /* 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 160 /* Parameter */: + case 161 /* Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -45567,7 +46664,7 @@ var ts; } } break; - case 198 /* BindingElement */: + case 199 /* BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -45575,7 +46672,7 @@ var ts; } } break; - case 185 /* InferType */: + case 186 /* InferType */: if (meaning & 262144 /* TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { @@ -45599,7 +46696,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 297 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 298 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -45658,7 +46755,7 @@ var ts; } // Perform extra checks only if error reporting was requested if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(compilerOptions.target === 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. @@ -45728,10 +46825,10 @@ var ts; } } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 209 /* ArrowFunction */ && location.kind !== 208 /* FunctionExpression */) { + if (location.kind !== 210 /* ArrowFunction */ && location.kind !== 209 /* 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 === 163 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 164 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -45744,12 +46841,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: // For `namespace N { N; }` + case 252 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 256 /* EnumDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 257 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -45759,12 +46856,14 @@ var ts; return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg); } function isTypeParameterSymbolDeclaredInContainer(symbol, container) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (decl.kind === 159 /* 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 + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (decl.kind === 160 /* 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 + } } } } @@ -45817,9 +46916,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -45863,7 +46962,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 === 270 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 271 /* ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } @@ -45932,13 +47031,14 @@ var ts; return false; } function checkResolvedBlockScopedVariable(result, errorLocation) { + var _a; ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 255 /* 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 === 256 /* EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { @@ -45973,20 +47073,20 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return node; - case 262 /* ImportClause */: + case 263 /* ImportClause */: return node.parent; - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: return node.parent.parent; - case 265 /* ImportSpecifier */: + case 266 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; } } function getDeclarationOfAliasSymbol(symbol) { - return ts.find(symbol.declarations, isAliasSymbolDeclaration); + return symbol.declarations && ts.findLast(symbol.declarations, isAliasSymbolDeclaration); } /** * An alias symbol is created by one of the following declarations: @@ -46001,25 +47101,26 @@ var ts; * module.exports = * {} * {name: } + * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 260 /* ImportEqualsDeclaration */ - || node.kind === 259 /* NamespaceExportDeclaration */ - || node.kind === 262 /* ImportClause */ && !!node.name - || node.kind === 263 /* NamespaceImport */ - || node.kind === 269 /* NamespaceExport */ - || node.kind === 265 /* ImportSpecifier */ - || node.kind === 270 /* ExportSpecifier */ - || node.kind === 266 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + return node.kind === 261 /* ImportEqualsDeclaration */ + || node.kind === 260 /* NamespaceExportDeclaration */ + || node.kind === 263 /* ImportClause */ && !!node.name + || node.kind === 264 /* NamespaceImport */ + || node.kind === 270 /* NamespaceExport */ + || node.kind === 266 /* ImportSpecifier */ + || node.kind === 271 /* ExportSpecifier */ + || node.kind === 267 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 289 /* ShorthandPropertyAssignment */ - || node.kind === 288 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true); + || node.kind === 290 /* ShorthandPropertyAssignment */ + || node.kind === 289 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || ts.isRequireVariableDeclaration(node); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -46032,7 +47133,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 273 /* ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -46099,6 +47200,7 @@ var ts; return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), /*sourceNode*/ undefined, dontResolveAlias); } function getTargetOfImportClause(node, dontResolveAlias) { + var _a; var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -46108,7 +47210,7 @@ var ts; else { exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); } - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias); if (!exportDefaultSymbol && !hasSyntheticDefault) { if (hasExportAssignmentSymbol(moduleSymbol)) { @@ -46116,7 +47218,9 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); - ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + if (exportAssignment) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); + } } else { reportNonDefaultExport(moduleSymbol, node); @@ -46133,7 +47237,7 @@ var ts; } } function reportNonDefaultExport(moduleSymbol, node) { - var _a, _b; + var _a, _b, _c; if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); } @@ -46141,7 +47245,7 @@ var ts; var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); if (exportStar) { - var defaultExport = ts.find(exportStar.declarations, function (decl) { + var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); @@ -46219,7 +47323,7 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var _a; + var _a, _b; if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSpecifier = ts.getExternalModuleRequireArgument(node) || node.moduleSpecifier; var moduleSymbol = resolveExternalModuleName(node, moduleSpecifier); // TODO: GH#18217 @@ -46228,7 +47332,7 @@ var ts; return undefined; } var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { @@ -46246,7 +47350,7 @@ var ts; symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { - var file = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } @@ -46266,7 +47370,7 @@ var ts; } } else { - if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -46279,8 +47383,8 @@ var ts; } } function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) { - var _a; - var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText); + var _a, _b; + var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); @@ -46292,9 +47396,11 @@ var ts; var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined; var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) : error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName); - ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { - return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); - }))); + if (localSymbol.declarations) { + ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { + return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); + }))); + } } } else { @@ -46381,31 +47487,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: - case 249 /* VariableDeclaration */: + case 261 /* ImportEqualsDeclaration */: + case 250 /* VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 262 /* ImportClause */: + case 263 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 269 /* NamespaceExport */: + case 270 /* NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 265 /* ImportSpecifier */: - case 198 /* BindingElement */: + case 266 /* ImportSpecifier */: + case 199 /* BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 270 /* ExportSpecifier */: + case 271 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 266 /* ExportAssignment */: - case 216 /* BinaryExpression */: + case 267 /* ExportAssignment */: + case 217 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 259 /* NamespaceExportDeclaration */: + case 260 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -46557,13 +47663,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 78 /* Identifier */ || entityName.parent.kind === 157 /* QualifiedName */) { + if (entityName.kind === 78 /* Identifier */ || entityName.parent.kind === 158 /* 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 === 260 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 261 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -46587,9 +47693,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 157 /* QualifiedName */ || name.kind === 201 /* PropertyAccessExpression */) { - var left = name.kind === 157 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 157 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 158 /* QualifiedName */ || name.kind === 202 /* PropertyAccessExpression */) { + var left = name.kind === 158 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 158 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -46597,18 +47703,17 @@ var ts; else if (namespace === unknownSymbol) { return namespace; } - if (ts.isInJSFile(name)) { - if (namespace.valueDeclaration && - ts.isVariableDeclaration(namespace.valueDeclaration) && - namespace.valueDeclaration.initializer && - isCommonJsRequire(namespace.valueDeclaration.initializer)) { - var moduleName = namespace.valueDeclaration.initializer.arguments[0]; - var moduleSym = resolveExternalModuleName(moduleName, moduleName); - if (moduleSym) { - var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); - if (resolvedModuleSymbol) { - namespace = resolvedModuleSymbol; - } + if (namespace.valueDeclaration && + ts.isInJSFile(namespace.valueDeclaration) && + ts.isVariableDeclaration(namespace.valueDeclaration) && + namespace.valueDeclaration.initializer && + isCommonJsRequire(namespace.valueDeclaration.initializer)) { + var moduleName = namespace.valueDeclaration.initializer.arguments[0]; + var moduleSym = resolveExternalModuleName(moduleName, moduleName); + if (moduleSym) { + var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym); + if (resolvedModuleSymbol) { + namespace = resolvedModuleSymbol; } } } @@ -46629,7 +47734,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 === 266 /* ExportAssignment */)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 267 /* ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -46866,7 +47971,7 @@ var ts; function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 297 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 298 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -46917,7 +48022,10 @@ var ts; var exports = getExportsOfModuleAsArray(moduleSymbol); var exportEquals = resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) { - ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals))); + var type = getTypeOfSymbol(exportEquals); + if (shouldTreatPropertiesOfExternalModuleAsExports(type)) { + ts.addRange(exports, getPropertiesOfType(type)); + } } return exports; } @@ -46937,11 +48045,14 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 131068 /* Primitive */ || - ts.getObjectFlags(type) & 1 /* Class */ || - isArrayOrTupleLikeType(type) - ? undefined - : getPropertyOfType(type, memberName); + return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; + } + function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { + return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path + isArrayType(resolvedExternalModuleType) || + isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : @@ -46999,11 +48110,13 @@ var ts; if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); - for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - var exportedSymbols = visit(resolvedModule); - extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + if (exportStars.declarations) { + for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + var exportedSymbols = visit(resolvedModule); + extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node); + } } lookupTable_1.forEach(function (_a, id) { var exportsWithDuplicate = _a.exportsWithDuplicate; @@ -47086,11 +48199,28 @@ var ts; var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); - if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + if (enclosingDeclaration && + container.flags & getQualifiedLeftMeaning(meaning) && + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } - var res = ts.append(ts.append(additionalContainers, container), objectLiteralContainer); - return ts.concatenate(res, reexportContainers); + // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type + // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) + var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) + && container.flags & 788968 /* Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ + && meaning === 111551 /* Value */ + ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { + return ts.forEachEntry(t, function (s) { + if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { + return s; + } + }); + }) : undefined; + var res = firstVariableMatch ? __spreadArray(__spreadArray([firstVariableMatch], additionalContainers), [container]) : __spreadArray(__spreadArray([], additionalContainers), [container]); + res = ts.append(res, objectLiteralContainer); + res = ts.addRange(res, reexportContainers); + return res; } var candidates = ts.mapDefined(symbol.declarations, function (d) { if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { @@ -47168,7 +48298,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 === 166 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 167 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -47177,7 +48307,9 @@ var ts; var result = new Type(checker, flags); typeCount++; result.id = typeCount; - typeCatalog.push(result); + if (produceDiagnostics) { // Only record types from one checker + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.recordType(result); + } return result; } function createOriginType(flags) { @@ -47237,6 +48369,11 @@ var ts; }); return result || ts.emptyArray; } + function getNamedOrIndexSignatureMembers(members) { + var result = getNamedMembers(members); + var index = getIndexSymbolFromSymbolTable(members); + return index ? ts.concatenate(result, [index]) : result; + } function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) { var resolved = type; resolved.members = members; @@ -47271,28 +48408,28 @@ var ts; var _loop_8 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { - if (result = callback(location.locals)) { + if (result = callback(location.locals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true)) { return { value: result }; } } switch (location.kind) { - case 297 /* SourceFile */: + case 298 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred // to one another anyway) - if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) { + if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true)) { return { value: result }; } break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* 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 @@ -47318,7 +48455,7 @@ var ts; if (typeof state_2 === "object") return state_2.value; } - return callback(globals); + return callback(globals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true); } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace @@ -47338,11 +48475,11 @@ var ts; /** * @param {ignoreQualification} boolean Set when a symbol is being looked for through the exports of another symbol (meaning we have a route to qualify it already) */ - function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) { + function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification, isLocalNameLookup) { if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - var result = trySymbolTable(symbols, ignoreQualification); + var result = trySymbolTable(symbols, ignoreQualification, isLocalNameLookup); visitedSymbolTables.pop(); return result; } @@ -47360,7 +48497,7 @@ var ts; !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } - function trySymbolTable(symbols, ignoreQualification) { + function trySymbolTable(symbols, ignoreQualification, isLocalNameLookup) { // If symbol is directly available by its name in the symbol table if (isAccessible(symbols.get(symbol.escapedName), /*resolvedAliasSymbol*/ undefined, ignoreQualification)) { return [symbol]; @@ -47373,9 +48510,11 @@ var ts; && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) + // If we're looking up a local name to reference directly, omit namespace reexports, otherwise when we're trawling through an export list to make a dotted name, we can keep it + && (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, 270 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 271 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -47419,7 +48558,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, 270 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 271 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -47434,10 +48573,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 164 /* PropertyDeclaration */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: continue; default: return false; @@ -47475,7 +48614,7 @@ var ts; return hasAccessibleDeclarations; } } - else if (allowModules) { + if (allowModules) { if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { if (shouldComputeAliasesToMakeVisible) { earlyModuleBail = true; @@ -47567,10 +48706,10 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 298 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 298 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -47626,14 +48765,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 176 /* TypeQuery */ || + if (entityName.parent.kind === 177 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 158 /* ComputedPropertyName */) { + entityName.parent.kind === 159 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 157 /* QualifiedName */ || entityName.kind === 201 /* PropertyAccessExpression */ || - entityName.parent.kind === 260 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 158 /* QualifiedName */ || entityName.kind === 202 /* PropertyAccessExpression */ || + entityName.parent.kind === 261 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -47674,7 +48813,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) === 297 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 298 /* 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; @@ -47686,10 +48825,10 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructorType */ : 174 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 176 /* ConstructorType */ : 175 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructSignature */ : 169 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 171 /* ConstructSignature */ : 170 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -47729,14 +48868,14 @@ var ts; return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { - return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 814775659 /* NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824 /* IsClassInstanceClone */)); + return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -48070,7 +49209,9 @@ var ts; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 221 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ + && !getBaseTypeVariableOfClass(symbol) + && !(symbol.valueDeclaration && symbol.valueDeclaration.kind === 222 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); @@ -48101,7 +49242,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 === 297 /* SourceFile */ || declaration.parent.kind === 257 /* ModuleBlock */; + return declaration.parent.kind === 298 /* SourceFile */ || declaration.parent.kind === 258 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -48152,12 +49293,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 174 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 175 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 175 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 176 /* ConstructorType */, context); return signatureNode; } } @@ -48337,17 +49478,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 169 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 170 /* 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, 170 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 171 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; - if (resolvedType.objectFlags & 2048 /* ReverseMapped */) { + if (resolvedType.objectFlags & 1024 /* ReverseMapped */) { indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0 /* String */, context, createElidedInformationPlaceholder(context)); } else { @@ -48391,15 +49532,29 @@ var ts; } return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); } + function shouldUsePlaceholderForProperty(propertySymbol, context) { + var _a; + // Use placeholders for reverse mapped types we've either already descended into, or which + // are nested reverse mappings within a mapping over a non-anonymous type. The later is a restriction mostly just to + // reduce the blowup in printback size from doing, eg, a deep reverse mapping over `Window`. + // Since anonymous types usually come from expressions, this allows us to preserve the output + // for deep mappings which likely come from expressions, while truncating those parts which + // come from mappings over library functions. + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + && (ts.contains(context.reverseMappedStack, propertySymbol) + || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + } function addPropertyToElementList(propertySymbol, context, typeElements) { + var _a; var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); - var propertyType = propertyIsReverseMapped && context.flags & 33554432 /* InReverseMappedType */ ? + var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */ && isLateBoundName(propertySymbol.escapedName)) { var decl = ts.first(propertySymbol.declarations); - if (hasLateBindableName(decl)) { + if (propertySymbol.declarations && hasLateBindableName(decl)) { if (ts.isBinaryExpression(decl)) { var name = ts.getNameOfDeclaration(decl); if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { @@ -48411,29 +49566,34 @@ var ts; } } } - context.enclosingDeclaration = saveEnclosingDeclaration; + context.enclosingDeclaration = propertySymbol.valueDeclaration || ((_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a[0]) || saveEnclosingDeclaration; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); + context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { 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, 164 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 165 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { - var savedFlags = context.flags; - context.flags |= propertyIsReverseMapped ? 33554432 /* InReverseMappedType */ : 0; var propertyTypeNode = void 0; - if (propertyIsReverseMapped && !!(savedFlags & 33554432 /* InReverseMappedType */)) { + if (shouldUsePlaceholderForProperty(propertySymbol, context)) { propertyTypeNode = createElidedInformationPlaceholder(context); } else { + if (propertyIsReverseMapped) { + context.reverseMappedStack || (context.reverseMappedStack = []); + context.reverseMappedStack.push(propertySymbol); + } propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); + if (propertyIsReverseMapped) { + context.reverseMappedStack.pop(); + } } - context.flags = savedFlags; var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; @@ -48442,9 +49602,10 @@ var ts; typeElements.push(preserveCommentsOn(propertySignature)); } function preserveCommentsOn(node) { - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; })) { - var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 333 /* JSDocPropertyTag */; }); - var commentText = d.comment; + var _a; + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 337 /* JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 337 /* JSDocPropertyTag */; }); + 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 }]); } @@ -48473,25 +49634,25 @@ var ts; var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; - var result_4 = []; + var result_5 = []; var i = 0; for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_4.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { - result_4.push(typeNode_1); + result_5.push(typeNode_1); } break; } context.approximateLength += 2; // Account for whitespace + separator var typeNode = typeToTypeNodeHelper(type, context); if (typeNode) { - result_4.push(typeNode); + result_5.push(typeNode); if (seenNames && ts.isIdentifierTypeReference(typeNode)) { - seenNames.add(typeNode.typeName.escapedText, [type, result_4.length - 1]); + seenNames.add(typeNode.typeName.escapedText, [type, result_5.length - 1]); } } } @@ -48513,13 +49674,13 @@ var ts; })) { for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { var _a = types_3[_i], type = _a[0], resultIndex = _a[1]; - result_4[resultIndex] = typeToTypeNodeHelper(type, context); + result_5[resultIndex] = typeToTypeNodeHelper(type, context); } } }); context.flags = saveContextFlags; } - return result_4; + return result_5; } } function typesAreSameReference(a, b) { @@ -48561,7 +49722,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 === 166 /* 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 === 167 /* 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); @@ -48588,25 +49749,25 @@ var ts; } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 175 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 176 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { var flags = ts.modifiersToFlags(modifiers); modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum - var node = kind === 169 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 170 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 164 /* 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 === 165 /* 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 === 166 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === 167 /* 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 === 168 /* 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 === 171 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : - kind === 308 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 174 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 175 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 251 /* 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 === 208 /* 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 === 209 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + var node = kind === 170 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 171 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 165 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 166 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 167 /* Constructor */ ? ts.factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : + kind === 168 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 169 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 172 /* IndexSignature */ ? ts.factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === 309 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 175 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 176 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 252 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 209 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 210 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -48628,9 +49789,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 160 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 161 /* Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 326 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 330 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -48645,7 +49806,7 @@ var ts; var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 78 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 157 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 158 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -48810,11 +49971,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var _a; - var file = ts.getDeclarationOfKind(symbol, 297 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 298 /* SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 297 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 298 /* SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -48825,8 +49986,8 @@ var ts; if (context.tracker.trackReferencedAmbientModule) { var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); if (ts.length(ambientDecls)) { - for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) { - var decl = ambientDecls_1[_i]; + for (var _i = 0, _b = ambientDecls; _i < _b.length; _i++) { + var decl = _b[_i]; context.tracker.trackReferencedAmbientModule(decl, symbol); } } @@ -48853,7 +50014,7 @@ var ts; // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; - specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); + specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "project-relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined })); (_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map()); links.specifierCache.set(contextFile.path, specifier); } @@ -48997,7 +50158,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -49077,9 +50238,6 @@ var ts; if (fromNameType) { return fromNameType; } - if (ts.isKnownSymbol(symbol)) { - return ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Symbol"), symbol.escapedName.substr(3))); - } var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed); return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote); @@ -49146,13 +50304,13 @@ var ts; function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { if (type !== errorType && enclosingDeclaration) { var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); - if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation) && !ts.isGetAccessorDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { - var result_5 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); - if (result_5) { - return result_5; + var result_6 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); + if (result_6) { + return result_6; } } } @@ -49169,10 +50327,14 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { - var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); - if (result) { - return result; + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { + var annotated = getTypeFromTypeNode(annotation); + var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); + if (result) { + return result; + } } } } @@ -49216,7 +50378,7 @@ 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 === 310 /* JSDocNamepathType */) { + if (ts.isJSDocAllType(node) || node.kind === 311 /* JSDocNamepathType */) { return ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { @@ -49335,8 +50497,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 165 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 164 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 166 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 165 /* MethodSignature */, /*useAcessors*/ false); // 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 @@ -49557,6 +50719,7 @@ var ts; // If it's a class/interface/function: emit a class/interface/function with a `default` modifier // These forms can merge, eg (`export default 12; export default interface A {}`) function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var _a, _b; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); var isDefault = symbol.escapedName === "default" /* Default */; if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { @@ -49615,9 +50778,9 @@ var ts; if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; } - var propertyAccessRequire = ts.find(symbol.declarations, ts.isPropertyAccessExpression); + var propertyAccessRequire = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isPropertyAccessExpression); if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right) - && type.symbol && ts.isSourceFile(type.symbol.valueDeclaration)) { + && ((_b = type.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isSourceFile(type.symbol.valueDeclaration)) { var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*decorators*/ undefined, @@ -49667,7 +50830,10 @@ var ts; serializeEnum(symbol, symbolName, modifierFlags); } if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { + if (symbol.flags & 4 /* Property */ + && symbol.valueDeclaration + && ts.isBinaryExpression(symbol.valueDeclaration.parent) + && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. @@ -49693,12 +50859,14 @@ var ts; if (symbol.flags & 8388608 /* ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var node = _a[_i]; - var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); - if (!resolvedModule) - continue; - addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + if (symbol.declarations) { + for (var _i = 0, _c = symbol.declarations; _i < _c.length; _i++) { + var node = _c[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } } } if (needsPostExportDefault) { @@ -49760,11 +50928,12 @@ var ts; results.push(node); } function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var _a; var aliasType = getDeclaredTypeOfTypeAlias(symbol); var typeParams = getSymbolLinks(symbol).typeParameters; var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); - var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); - var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); + var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; context.flags |= 8388608 /* InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; @@ -49784,8 +50953,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, 169 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 170 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 170 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 171 /* ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( @@ -49854,9 +51023,8 @@ 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, 251 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); - // for expressions assigned to `var`s, use the `var` as the text range - addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags); + var decl = signatureToSignatureDeclarationHelper(sig, 252 /* 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 if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { @@ -49864,6 +51032,18 @@ var ts; serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } + function getSignatureTextRangeLocation(signature) { + if (signature.declaration && signature.declaration.parent) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + return signature.declaration.parent; + } + // for expressions assigned to `var`s, use the `var` as the text range + if (ts.isVariableDeclaration(signature.declaration.parent) && signature.declaration.parent.parent) { + return signature.declaration.parent.parent; + } + } + return signature.declaration; + } function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { if (ts.length(props)) { var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { @@ -49950,8 +51130,8 @@ var ts; return undefined; } function serializeAsClass(symbol, localName, modifierFlags) { - var _a; - var originalDecl = ts.find(symbol.declarations, ts.isClassLike); + var _a, _b; + var originalDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isClassLike); var oldEnclosing = context.enclosingDeclaration; context.enclosingDeclaration = originalDecl || oldEnclosing; var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -49962,7 +51142,7 @@ var ts; var implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements) || ts.mapDefined(getImplementsTypes(classType), serializeImplementedType); var staticType = getTypeOfSymbol(symbol); - var isClass = !!((_a = staticType.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); + var isClass = !!((_b = staticType.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration); var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; @@ -49973,14 +51153,14 @@ var ts; // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); + return !!valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); }); var hasPrivateIdentifier = ts.some(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from // a union/intersection base type, but inherited properties // don't matter here. var valueDecl = s.valueDeclaration; - return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); + return !!valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); }); // Boil down all private properties into a single one. var privateProperties = hasPrivateIdentifier ? @@ -50003,7 +51183,7 @@ 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, 166 /* Constructor */); + serializeSignatures(1 /* Construct */, staticType, staticBaseType, 167 /* Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -50030,8 +51210,8 @@ var ts; var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 198 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 249 /* VariableDeclaration */) { + case 199 /* BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 250 /* VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; @@ -50043,13 +51223,13 @@ var ts; // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 289 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 216 /* BinaryExpression */) { + case 290 /* ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 217 /* BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -50069,7 +51249,7 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 260 /* ImportEqualsDeclaration */: + case 261 /* 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)) { @@ -50086,13 +51266,13 @@ var ts; ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); break; - case 259 /* NamespaceExportDeclaration */: + case 260 /* 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 262 /* ImportClause */: + case 263 /* ImportClause */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), @@ -50101,18 +51281,18 @@ var ts; // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); break; - case 269 /* NamespaceExport */: + case 270 /* 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 265 /* ImportSpecifier */: + case 266 /* ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause( @@ -50121,7 +51301,7 @@ var ts; ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); break; - case 270 /* ExportSpecifier */: + case 271 /* 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; @@ -50129,12 +51309,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 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 216 /* BinaryExpression */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 217 /* BinaryExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* 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 @@ -50268,6 +51448,7 @@ var ts; } function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { return function serializePropertySymbol(p, isStatic, baseType) { + var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); var isPrivate = !!(modifierFlags & 8 /* Private */); if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { @@ -50284,7 +51465,7 @@ var ts; } var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); - var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); if (p.flags & 98304 /* Accessor */ && useAccessors) { var result = []; if (p.flags & 65536 /* SetAccessor */) { @@ -50294,13 +51475,13 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], - /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } if (p.flags & 32768 /* GetAccessor */) { var isPrivate_1 = modifierFlags & 8 /* Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), - /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } return result; } @@ -50311,7 +51492,7 @@ var ts; /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ - /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } if (p.flags & (8192 /* Method */ | 16 /* Function */)) { var type = getTypeOfSymbol(p); @@ -50320,7 +51501,7 @@ var ts; return ts.setTextRange(createProperty( /*decorators*/ undefined, ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, /*type*/ undefined, - /*initializer*/ undefined), ts.find(p.declarations, ts.isFunctionLikeDeclaration) || signatures[0] && signatures[0].declaration || p.declarations[0]); + /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } var results_1 = []; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { @@ -50331,7 +51512,8 @@ var ts; questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); - results_1.push(ts.setTextRange(decl, sig.declaration)); + var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; + results_1.push(ts.setTextRange(decl, location)); } return results_1; } @@ -50547,9 +51729,9 @@ var ts; return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { + if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 254 /* TypeAliasDeclaration */) { + if (node.kind === 255 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -50557,11 +51739,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 257 /* ModuleBlock */ && + node.parent.kind === 258 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 297 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 298 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; @@ -50620,17 +51802,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 249 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 250 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 222 /* ClassExpression */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 221 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 222 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -50647,28 +51829,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: + case 328 /* JSDocCallbackTag */: + case 335 /* JSDocTypedefTag */: + case 329 /* 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 198 /* BindingElement */: + case 199 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 249 /* VariableDeclaration */: + case 250 /* 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 251 /* FunctionDeclaration */: - case 255 /* EnumDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 257 /* ModuleDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 252 /* FunctionDeclaration */: + case 256 /* EnumDeclaration */: + case 261 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -50676,55 +51858,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 !== 260 /* ImportEqualsDeclaration */ && parent.kind !== 297 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { + !(node.kind !== 261 /* ImportEqualsDeclaration */ && parent.kind !== 298 /* 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 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 165 /* 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 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 160 /* Parameter */: - case 257 /* ModuleBlock */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 173 /* TypeReference */: - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 167 /* Constructor */: + case 171 /* ConstructSignature */: + case 170 /* CallSignature */: + case 172 /* IndexSignature */: + case 161 /* Parameter */: + case 258 /* ModuleBlock */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: + case 178 /* TypeLiteral */: + case 174 /* TypeReference */: + case 179 /* ArrayType */: + case 180 /* TupleType */: + case 183 /* UnionType */: + case 184 /* IntersectionType */: + case 187 /* ParenthesizedType */: + case 193 /* NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: + case 263 /* ImportClause */: + case 264 /* NamespaceImport */: + case 266 /* ImportSpecifier */: return false; // Type parameters are always visible - case 159 /* TypeParameter */: + case 160 /* TypeParameter */: // Source file and namespace export are always visible // falls through - case 297 /* SourceFile */: - case 259 /* NamespaceExportDeclaration */: + case 298 /* SourceFile */: + case 260 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return false; default: return false; @@ -50733,10 +51915,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 266 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 267 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 270 /* ExportSpecifier */) { + else if (node.parent.kind === 271 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -50841,12 +52023,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 249 /* VariableDeclaration */: - case 250 /* VariableDeclarationList */: - case 265 /* ImportSpecifier */: - case 264 /* NamedImports */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: + case 250 /* VariableDeclaration */: + case 251 /* VariableDeclarationList */: + case 266 /* ImportSpecifier */: + case 265 /* NamedImports */: + case 264 /* NamespaceImport */: + case 263 /* ImportClause */: return false; default: return true; @@ -50909,9 +52091,16 @@ var ts; var stringIndexInfo = getIndexInfoOfType(source, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(source, 1 /* Number */); var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= 131072 /* ObjectRestType */; + result.objectFlags |= 8388608 /* ObjectRestType */; return result; } + function isGenericTypeWithUndefinedConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + } + function getNonUndefinedType(type) { + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: // let { x } = obj; // BindingElement @@ -50946,23 +52135,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 198 /* BindingElement */: - case 288 /* PropertyAssignment */: + case 199 /* BindingElement */: + case 289 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return ancestor.initializer; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 198 /* BindingElement */ && parent.kind === 196 /* ObjectBindingPattern */) { + if (node.kind === 199 /* BindingElement */ && parent.kind === 197 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 288 /* PropertyAssignment */ || node.kind === 289 /* ShorthandPropertyAssignment */) { + if (node.kind === 289 /* PropertyAssignment */ || node.kind === 290 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -50988,7 +52177,7 @@ var ts; parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); } var type; - if (pattern.kind === 196 /* ObjectBindingPattern */) { + if (pattern.kind === 197 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { @@ -51008,7 +52197,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getConstraintForLocation(getIndexedAccessType(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */), declaration.name); + var declaredType = getIndexedAccessType(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -51029,7 +52218,7 @@ var ts; else if (isArrayLikeType(parentType)) { var indexType = getLiteralType(index_2); var accessFlags = hasDefaultValue(declaration) ? 8 /* NoTupleBoundsCheck */ : 0; - var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, declaration.name, accessFlags | 16 /* ExpressionPosition */) || errorType, declaration.name); + var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, /*noUncheckedIndexedAccessCandidate*/ undefined, declaration.name, accessFlags | 16 /* ExpressionPosition */) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } else { @@ -51042,11 +52231,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? - getTypeWithFacts(type, 524288 /* NEUndefined */) : - type; + return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768 /* Undefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration)], 2 /* Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -51061,7 +52248,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 199 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 200 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -51071,11 +52258,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 === 238 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* 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 === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 240 /* 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, @@ -51112,8 +52299,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 === 168 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 167 /* GetAccessor */); + if (func.kind === 169 /* SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 168 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -51184,7 +52371,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 202 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 203 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -51200,13 +52387,33 @@ var ts; !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration)); } function getDeclaringConstructor(symbol) { + if (!symbol.declarations) { + return; + } 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 === 166 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 167 /* Constructor */ || isJSConstructor(container))) { return container; } } + ; + } + /** Create a synthetic property access flow node after the last statement of the file */ + function getFlowTypeFromCommonJSExport(symbol) { + var file = ts.getSourceFileOfNode(symbol.declarations[0]); + var accessName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var areAllModuleExports = symbol.declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && ts.isModuleExportsAccessExpression(d.expression); }); + var reference = areAllModuleExports + ? ts.factory.createPropertyAccessExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("module"), ts.factory.createIdentifier("exports")), accessName) + : ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), accessName); + if (areAllModuleExports) { + ts.setParent(reference.expression.expression, reference.expression); + } + ts.setParent(reference.expression, reference); + ts.setParent(reference, file); + reference.flowNode = file.endFlowNode; + return getFlowTypeOfReference(reference, autoType, undefinedType); } function getFlowTypeInConstructor(symbol, constructor) { var accessName = ts.startsWith(symbol.escapedName, "__#") @@ -51224,7 +52431,10 @@ var ts; return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType); } function getFlowTypeOfProperty(reference, prop) { - var initialType = prop && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; + var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && getTypeOfPropertyInBaseClass(prop) + || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); } function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) { @@ -51235,7 +52445,7 @@ var ts; if (tag && tag.typeExpression) { return getTypeFromTypeNode(tag.typeExpression); } - var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container); + var containerObjectType = symbol.valueDeclaration && getJSContainerObjectType(symbol.valueDeclaration, symbol, container); return containerObjectType || getWidenedLiteralType(checkExpressionCached(container)); } var type; @@ -51247,40 +52457,42 @@ var ts; type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol)); } if (!type) { - var jsdocType = void 0; var types = void 0; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : - undefined; - if (!expression) { - continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere - } - var kind = ts.isAccessExpression(expression) - ? ts.getAssignmentDeclarationPropertyAccessKind(expression) - : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { - if (isDeclarationInConstructor(expression)) { - definedInConstructor = true; + if (symbol.declarations) { + var jsdocType = void 0; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + undefined; + if (!expression) { + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - else { - definedInMethod = true; + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); + if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (isDeclarationInConstructor(expression)) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (!ts.isCallExpression(expression)) { + jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); + } + if (!jsdocType) { + (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); } } - if (!ts.isCallExpression(expression)) { - jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration); - } - if (!jsdocType) { - (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType); - } + type = jsdocType; } - type = jsdocType; if (!type) { if (!ts.length(types)) { return errorType; // No types from any declarations :( } - var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; + var constructorTypes = definedInConstructor && symbol.declarations ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { var propType = getTypeOfPropertyInBaseClass(symbol); @@ -51294,7 +52506,7 @@ var ts; } } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -51318,10 +52530,11 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined); - type.objectFlags |= 16384 /* JSLiteral */; + type.objectFlags |= 8192 /* JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { + var _a; var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent); if (typeNode) { var type = getWidenedType(getTypeFromTypeNode(typeNode)); @@ -51332,7 +52545,7 @@ var ts; errorNextVariableOrPropertyDeclarationMustHaveSameType(/*firstDeclaration*/ undefined, declaredType, declaration, type); } } - if (symbol.parent) { + if ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) { var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration); if (typeNode_2) { return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName); @@ -51396,7 +52609,7 @@ var ts; // but we may have a JS file with `module.exports = { a: true }` along with a TypeScript module augmentation // declaring an `export const a: number`. In that case, we issue a duplicate identifier error, because // it's unclear what that's supposed to mean, so it's probably a mistake. - if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { + if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName); var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration; ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName)); @@ -51418,9 +52631,9 @@ var ts; }); var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, // Only set the type's symbol if it looks to be the same as the original type members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); - result.objectFlags |= (ts.getObjectFlags(type) & 16384 /* JSLiteral */); // Propagate JSLiteral flag + result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 1073741824 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -51439,9 +52652,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 === 166 /* Constructor */ || - thisContainer.kind === 251 /* FunctionDeclaration */ || - (thisContainer.kind === 208 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 167 /* Constructor */ || + thisContainer.kind === 252 /* FunctionDeclaration */ || + (thisContainer.kind === 209 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -51479,7 +52692,7 @@ var ts; function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -51503,7 +52716,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51511,7 +52724,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 198 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 199 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -51522,7 +52735,7 @@ var ts; if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 262144 /* ContainsObjectOrArrayLiteral */; } return result; } @@ -51536,7 +52749,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 196 /* ObjectBindingPattern */ + return pattern.kind === 197 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -51552,8 +52765,17 @@ var ts; function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true), declaration, reportErrors); } + function isGlobalSymbolConstructor(node) { + var symbol = getSymbolOfNode(node); + var globalSymbol = getGlobalESSymbolConstructorTypeSymbol(/*reportErrors*/ false); + return globalSymbol && symbol && symbol === globalSymbol; + } function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { + // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` + if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + type = getESSymbolLikeTypeForNode(declaration); + } if (reportErrors) { reportErrorsFromWidening(declaration, type); } @@ -51575,7 +52797,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 160 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 161 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -51606,7 +52828,7 @@ var ts; if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */) { + if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -51623,12 +52845,14 @@ var ts; return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined); } // Handle catch clause variables + ts.Debug.assertIsDefined(symbol.valueDeclaration); var declaration = symbol.valueDeclaration; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { - var decl = declaration; - if (!decl.type) + var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); + if (typeNode === undefined) { return anyType; - var type_1 = getTypeOfNode(decl.type); + } + var type_1 = getTypeOfNode(typeNode); // an errorType will make `checkTryStatement` issue an error return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType; } @@ -51648,7 +52872,7 @@ var ts; return reportCircularityError(symbol); } var type; - if (declaration.kind === 266 /* ExportAssignment */) { + if (declaration.kind === 267 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -51703,7 +52927,7 @@ var ts; type = getTypeOfEnumMember(symbol); } else if (ts.isAccessor(declaration)) { - type = resolveTypeOfAccessors(symbol); + type = resolveTypeOfAccessors(symbol) || ts.Debug.fail("Non-write accessor resolution must always produce a type"); } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); @@ -51719,7 +52943,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 167 /* GetAccessor */) { + if (accessor.kind === 168 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -51743,63 +52967,78 @@ var ts; } function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); - return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); + return links.type || (links.type = getTypeOfAccessorsWorker(symbol) || ts.Debug.fail("Read type of accessor must always produce a type")); + } + function getTypeOfSetAccessor(symbol) { + var links = getSymbolLinks(symbol); + return links.writeType || (links.writeType = getTypeOfAccessorsWorker(symbol, /*writing*/ true)); } - function getTypeOfAccessorsWorker(symbol) { + function getTypeOfAccessorsWorker(symbol, writing) { + if (writing === void 0) { writing = false; } if (!pushTypeResolution(symbol, 0 /* Type */)) { return errorType; } - var type = resolveTypeOfAccessors(symbol); + var type = resolveTypeOfAccessors(symbol, writing); if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 168 /* 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)); } } return type; } - function resolveTypeOfAccessors(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 167 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 168 /* SetAccessor */); + function resolveTypeOfAccessors(symbol, writing) { + if (writing === void 0) { writing = false; } + var getter = ts.getDeclarationOfKind(symbol, 168 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 169 /* SetAccessor */); + var setterType = getAnnotatedAccessorType(setter); + // For write operations, prioritize type annotations on the setter + if (writing && setterType) { + return instantiateTypeIfNeeded(setterType, symbol); + } + // Else defer to the getter type if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { - return jsDocType; + return instantiateTypeIfNeeded(jsDocType, symbol); } } - // First try to see if the user specified a return type on the get-accessor. - var getterReturnType = getAnnotatedAccessorType(getter); - if (getterReturnType) { - return getterReturnType; + // Try to see if the user specified a return type on the get-accessor. + var getterType = getAnnotatedAccessorType(getter); + if (getterType) { + return instantiateTypeIfNeeded(getterType, symbol); } - else { - // If the user didn't specify a return type, try to use the set-accessor's parameter type. - var setterParameterType = getAnnotatedAccessorType(setter); - if (setterParameterType) { - return setterParameterType; + // If the user didn't specify a return type, try to use the set-accessor's parameter type. + if (setterType) { + return setterType; + } + // If there are no specified types, try to infer it from the body of the get accessor if it exists. + if (getter && getter.body) { + var returnTypeFromBody = getReturnTypeFromBody(getter); + return instantiateTypeIfNeeded(returnTypeFromBody, symbol); + } + // Otherwise, fall back to 'any'. + if (setter) { + if (!isPrivateWithinAmbient(setter)) { + errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } - else { - // If there are no specified types, try to infer it from the body of the get accessor if it exists. - if (getter && getter.body) { - return getReturnTypeFromBody(getter); - } - // Otherwise, fall back to 'any'. - else { - if (setter) { - if (!isPrivateWithinAmbient(setter)) { - errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); - } - } - else { - ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); - if (!isPrivateWithinAmbient(getter)) { - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); - } - } - return anyType; - } + return anyType; + } + else if (getter) { + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + } + return anyType; + } + return undefined; + function instantiateTypeIfNeeded(type, symbol) { + if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + var links = getSymbolLinks(symbol); + return instantiateType(type, links.mapper); } + return type; } } function getBaseTypeVariableOfClass(symbol) { @@ -51829,9 +53068,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 216 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 217 /* BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 216 /* BinaryExpression */)) { + declaration.parent.kind === 217 /* BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -51865,14 +53104,16 @@ var ts; var links = getSymbolLinks(symbol); if (!links.type) { var targetSymbol = resolveAlias(symbol); + var exportSymbol = symbol.declarations && getTargetOfAliasDeclaration(getDeclarationOfAliasSymbol(symbol), /*dontResolveAlias*/ true); // 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. // This check is important because without it, a call to getTypeOfSymbol could end // up recursively calling getTypeOfAlias, causing a stack overflow. - links.type = targetSymbol.flags & 111551 /* Value */ - ? getTypeOfSymbol(targetSymbol) - : errorType; + 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; } return links.type; } @@ -51898,7 +53139,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 160 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 161 /* 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 @@ -51915,6 +53156,15 @@ var ts; } return links.type; } + function getSetAccessorTypeOfSymbol(symbol) { + if (symbol.flags & 98304 /* Accessor */) { + var type = getTypeOfSetAccessor(symbol); + if (type) { + return type; + } + } + return getTypeOfSymbol(symbol); + } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); if (checkFlags & 65536 /* DeferredType */) { @@ -51997,66 +53247,72 @@ var ts; return undefined; } switch (node.kind) { - case 232 /* VariableStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 164 /* MethodSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 308 /* JSDocFunctionType */: - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: - case 331 /* JSDocTypedefTag */: - case 325 /* JSDocEnumTag */: - case 324 /* JSDocCallbackTag */: - case 190 /* MappedType */: - case 184 /* ConditionalType */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 165 /* MethodSignature */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: + case 309 /* JSDocFunctionType */: + case 252 /* FunctionDeclaration */: + case 166 /* MethodDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 255 /* TypeAliasDeclaration */: + case 334 /* JSDocTemplateTag */: + case 335 /* JSDocTypedefTag */: + case 329 /* JSDocEnumTag */: + case 328 /* JSDocCallbackTag */: + case 191 /* MappedType */: + case 185 /* ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 190 /* MappedType */) { + if (node.kind === 191 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 184 /* ConditionalType */) { + else if (node.kind === 185 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } - else if (node.kind === 232 /* VariableStatement */ && !ts.isInJSFile(node)) { - break; - } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */ || node.kind === 253 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 253 /* ClassDeclaration */ || node.kind === 222 /* ClassExpression */ || node.kind === 254 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; - case 326 /* JSDocParameterTag */: + } + case 330 /* JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; + case 312 /* JSDocComment */: { + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + return node.tags + ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) + : outerTypeParameters; + } } } } // 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, 253 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 254 /* InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { + if (!symbol.declarations) { + return; + } var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 252 /* ClassDeclaration */ || - node.kind === 221 /* ClassExpression */ || + if (node.kind === 254 /* InterfaceDeclaration */ || + node.kind === 253 /* ClassDeclaration */ || + node.kind === 222 /* ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -52150,7 +53406,9 @@ var ts; ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } } - ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + if (baseConstructorType.symbol.declarations) { + ts.addRelatedInfo(err, ts.createDiagnosticForNode(baseConstructorType.symbol.declarations[0], ts.Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn))); + } } return type.resolvedBaseConstructorType = errorType; } @@ -52160,20 +53418,22 @@ var ts; } function getImplementsTypes(type) { var resolvedImplementsTypes = ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); - if (!implementsTypeNodes) - continue; - 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 (resolvedImplementsTypes === ts.emptyArray) { - resolvedImplementsTypes = [implementsType]; - } - else { - resolvedImplementsTypes.push(implementsType); + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); + if (!implementsTypeNodes) + continue; + 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 (resolvedImplementsTypes === ts.emptyArray) { + resolvedImplementsTypes = [implementsType]; + } + else { + resolvedImplementsTypes.push(implementsType); + } } } } @@ -52200,10 +53460,10 @@ var ts; else { ts.Debug.fail("type must be class or interface"); } - if (!popTypeResolution()) { + if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 252 /* ClassDeclaration */ || declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 253 /* ClassDeclaration */ || declaration.kind === 254 /* InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -52296,29 +53556,31 @@ var ts; } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; - for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 253 /* 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 (isValidBaseType(baseType)) { - if (type !== baseType && !hasBaseType(baseType, type)) { - if (type.resolvedBaseTypes === ts.emptyArray) { - type.resolvedBaseTypes = [baseType]; + if (type.symbol.declarations) { + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 254 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + 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 (isValidBaseType(baseType)) { + if (type !== baseType && !hasBaseType(baseType, type)) { + if (type.resolvedBaseTypes === ts.emptyArray) { + type.resolvedBaseTypes = [baseType]; + } + else { + type.resolvedBaseTypes.push(baseType); + } } else { - type.resolvedBaseTypes.push(baseType); + reportCircularBaseType(declaration, type); } } else { - reportCircularBaseType(declaration, type); + error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); } } - else { - error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members); - } } } } @@ -52332,9 +53594,12 @@ var ts; * and if none of the base interfaces have a "this" type. */ function isThislessInterface(symbol) { + if (!symbol.declarations) { + return true; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 253 /* InterfaceDeclaration */) { + if (declaration.kind === 254 /* InterfaceDeclaration */) { if (declaration.flags & 128 /* ContainsThis */) { return false; } @@ -52359,7 +53624,7 @@ var ts; var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol symbol = links = merged; @@ -52389,6 +53654,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfTypeAlias(symbol) { + var _a; var links = getSymbolLinks(symbol); if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique @@ -52396,7 +53662,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found"); + var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -52422,7 +53688,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 216 /* BinaryExpression */) { + else if (expr.kind === 217 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -52437,12 +53703,12 @@ var ts; case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 78 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -52454,16 +53720,18 @@ var ts; return links.enumKind; } var hasNonLiteralMember = false; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* EnumDeclaration */) { - for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { - var member = _c[_b]; - if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; - } - if (!isLiteralEnumMember(member)) { - hasNonLiteralMember = true; + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 256 /* EnumDeclaration */) { + for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { + var member = _c[_b]; + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { + return links.enumKind = 1 /* Literal */; + } + if (!isLiteralEnumMember(member)) { + hasNonLiteralMember = true; + } } } } @@ -52481,15 +53749,17 @@ var ts; if (getEnumKind(symbol) === 1 /* Literal */) { enumCount++; var memberTypeList = []; - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.kind === 255 /* EnumDeclaration */) { - for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { - var member = _c[_b]; - var value = getEnumMemberValue(member); - var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); - getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; - memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 256 /* EnumDeclaration */) { + for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { + var member = _c[_b]; + var value = getEnumMemberValue(member); + var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member))); + getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; + memberTypeList.push(getRegularTypeOfLiteralType(memberType)); + } } } } @@ -52566,11 +53836,11 @@ var ts; case 113 /* VoidKeyword */: case 150 /* UndefinedKeyword */: case 141 /* NeverKeyword */: - case 191 /* LiteralType */: + case 192 /* LiteralType */: return true; - case 178 /* ArrayType */: + case 179 /* ArrayType */: return isThislessType(node.elementType); - case 173 /* TypeReference */: + case 174 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -52596,7 +53866,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 166 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 167 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -52612,14 +53882,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -52645,7 +53915,7 @@ var ts; } } function isStaticPrivateIdentifierProperty(s) { - return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); + return !!s.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32 /* Static */); } function resolveDeclaredMembers(type) { if (!type.declaredProperties) { @@ -52970,7 +54240,8 @@ var ts; sig.resolvedMinArgumentCount = undefined; sig.target = undefined; sig.mapper = undefined; - sig.unionSignatures = undefined; + sig.compositeSignatures = undefined; + sig.compositeKind = undefined; return sig; } function cloneSignature(sig) { @@ -52978,12 +54249,14 @@ var ts; /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; - result.unionSignatures = sig.unionSignatures; + result.compositeSignatures = sig.compositeSignatures; + result.compositeKind = sig.compositeKind; return result; } function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); - result.unionSignatures = unionSignatures; + result.compositeSignatures = unionSignatures; + result.compositeKind = 1048576 /* Union */; result.target = undefined; result.mapper = undefined; return result; @@ -53142,7 +54415,7 @@ var ts; if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); - results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); + results = !!signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); }); if (!results) { return "break"; } @@ -53159,9 +54432,12 @@ var ts; return result || ts.emptyArray; } function compareTypeParametersIdentical(sourceParams, targetParams) { - if (sourceParams.length !== targetParams.length) { + if (ts.length(sourceParams) !== ts.length(targetParams)) { return false; } + if (!sourceParams || !targetParams) { + return true; + } var mapper = createTypeMapper(targetParams, sourceParams); for (var i = 0; i < sourceParams.length; i++) { var source = sourceParams[i]; @@ -53243,9 +54519,10 @@ var ts; var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); + result.compositeKind = 1048576 /* Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.mapper && left.unionSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -53378,6 +54655,7 @@ var ts; // Combinations of function, class, enum and module var members = emptySymbols; var stringIndexInfo = void 0; + var numberIndexInfo = void 0; if (symbol.exports) { members = getExportsOfSymbol(symbol); if (symbol === globalThisSymbol) { @@ -53390,20 +54668,31 @@ var ts; members = varsOnly_1; } } + var baseConstructorIndexInfo = void 0; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined); if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { - members = ts.createSymbolTable(getNamedMembers(members)); + members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } else if (baseConstructorType === anyType) { - stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + baseConstructorIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + } + } + var indexSymbol = getIndexSymbolFromSymbolTable(members); + if (indexSymbol) { + stringIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 0 /* String */); + numberIndexInfo = getIndexInfoOfIndexSymbol(indexSymbol, 1 /* Number */); + } + else { + stringIndexInfo = baseConstructorIndexInfo; + if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + numberIndexInfo = enumNumberIndexInfo; } } - var numberIndexInfo = symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); })) ? enumNumberIndexInfo : undefined; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); // We resolve the members before computing the signatures because a signature may use // typeof with a qualified name expression that circularly references the type we are @@ -53428,6 +54717,18 @@ var ts; } } } + function replaceIndexedAccess(instantiable, type, replacement) { + // map type.indexType to 0 + // map type.objectType to `[TReplacement]` + // thus making the indexed access `[TReplacement][0]` or `TReplacement` + return instantiateType(instantiable, createTypeMapper([type.indexType, type.objectType], [getLiteralType(0), createTupleType([replacement])])); + } + function getIndexInfoOfIndexSymbol(indexSymbol, indexKind) { + var declaration = getIndexDeclarationOfIndexSymbol(indexSymbol, indexKind); + if (!declaration) + return undefined; + return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration); + } function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, 0 /* String */); var modifiers = getMappedTypeModifiers(type.mappedType); @@ -53442,8 +54743,21 @@ var ts; inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - inferredProp.mappedType = type.mappedType; - inferredProp.constraintType = type.constraintType; + if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is + // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of + // type identities produced, we simplify such indexed access occurences + var newTypeParam = type.constraintType.type.objectType; + var newMappedType = replaceIndexedAccess(type.mappedType, type.constraintType.type, newTypeParam); + inferredProp.mappedType = newMappedType; + inferredProp.constraintType = getIndexType(newTypeParam); + } + else { + inferredProp.mappedType = type.mappedType; + inferredProp.constraintType = type.constraintType; + } members.set(prop.escapedName, inferredProp); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); @@ -53605,7 +54919,7 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 188 /* TypeOperator */ && + return constraintDeclaration.kind === 189 /* TypeOperator */ && constraintDeclaration.operator === 138 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -53657,7 +54971,7 @@ var ts; else if (type.objectFlags & 3 /* ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 2048 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ReverseMapped */) { resolveReverseMappedTypeMembers(type); } else if (type.objectFlags & 16 /* Anonymous */) { @@ -54076,6 +55390,7 @@ var ts; return getReducedType(getApparentType(getReducedType(type))); } function createUnionOrIntersectionProperty(containingType, name, skipObjectFunctionPropertyAugment) { + var _a, _b; var singleProp; var propSet; var indexTypes; @@ -54084,8 +55399,9 @@ var ts; var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; var syntheticFlag = 4 /* SyntheticMethod */; var checkFlags = 0; - for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { - var current = _a[_i]; + 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 */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); @@ -54101,13 +55417,25 @@ var ts; singleProp = prop; } else if (prop !== singleProp) { - if (!propSet) { - propSet = new ts.Map(); - propSet.set(getSymbolId(singleProp), singleProp); + var isInstantiation = (getTargetSymbol(prop) || prop) === (getTargetSymbol(singleProp) || singleProp); + // If the symbols are instances of one another with identical types - consider the symbols + // equivalent and just use the first one, which thus allows us to avoid eliding private + // members when intersecting a (this-)instantiations of a class with it's raw base or another instance + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used + // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed + // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` + mergedInstantiations = !!singleProp.parent && !!ts.length(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(singleProp.parent)); } - var id = getSymbolId(prop); - if (!propSet.has(id)) { - propSet.set(id, prop); + else { + if (!propSet) { + propSet = new ts.Map(); + propSet.set(getSymbolId(singleProp), singleProp); + } + var id = getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } } } checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | @@ -54125,7 +55453,7 @@ var ts; checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type)) { + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 4194304 /* ContainsSpread */)) { checkFlags |= 32 /* WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } @@ -54141,7 +55469,19 @@ var ts; return undefined; } if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { - return singleProp; + if (mergedInstantiations) { + // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) + // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) + // They also have a `.containingType` set, which affects some services endpoints behavior, like `getRootSymbol` + var clone_1 = createSymbolWithType(singleProp, singleProp.type); + clone_1.parent = (_b = (_a = singleProp.valueDeclaration) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.parent; + clone_1.containingType = containingType; + clone_1.mapper = singleProp.mapper; + return clone_1; + } + else { + return singleProp; + } } var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp]; var declarations; @@ -54150,8 +55490,8 @@ var ts; var propTypes = []; var firstValueDeclaration; var hasNonUniformValueDeclaration = false; - for (var _b = 0, props_1 = props; _b < props_1.length; _b++) { - var prop = props_1[_b]; + for (var _d = 0, props_1 = props; _d < props_1.length; _d++) { + var prop = props_1[_d]; if (!firstValueDeclaration) { firstValueDeclaration = prop.valueDeclaration; } @@ -54228,15 +55568,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 268435456 /* ContainsIntersections */) { + if (type.flags & 1048576 /* Union */ && type.objectFlags & 67108864 /* ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 268435456 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 268435456 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 /* IsNeverIntersection */ : 0); + if (!(type.objectFlags & 67108864 /* IsNeverIntersectionComputed */)) { + type.objectFlags |= 67108864 /* IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 134217728 /* IsNeverIntersection */ : 0); } - return type.objectFlags & 536870912 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 134217728 /* IsNeverIntersection */ ? neverType : type; } return type; } @@ -54266,7 +55606,7 @@ var ts; return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (ts.getObjectFlags(type) & 536870912 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 134217728 /* IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); @@ -54353,7 +55693,8 @@ var ts; for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { - propTypes.push(getTypeOfSymbol(prop)); + var propType = getTypeOfSymbol(prop); + propTypes.push(prop.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType); } } if (kind === 0 /* String */) { @@ -54387,10 +55728,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 === 307 /* JSDocOptionalType */ + node.type && node.type.kind === 308 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 308 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -54422,12 +55763,15 @@ var ts; } return false; } + function isOptionalPropertyDeclaration(node) { + return ts.isPropertyDeclaration(node) && node.questionToken; + } function isOptionalJSDocPropertyLikeTag(node) { if (!ts.isJSDocPropertyLikeTag(node)) { return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 307 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 308 /* JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -54509,7 +55853,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 191 /* LiteralType */) { + if (type && type.kind === 192 /* LiteralType */) { flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter @@ -54522,16 +55866,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 === 167 /* GetAccessor */ || declaration.kind === 168 /* SetAccessor */) && + if ((declaration.kind === 168 /* GetAccessor */ || declaration.kind === 169 /* SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + var otherKind = declaration.kind === 168 /* GetAccessor */ ? 169 /* SetAccessor */ : 168 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 166 /* Constructor */ ? + var classType = declaration.kind === 167 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -54576,8 +55920,7 @@ var ts; if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node))) return undefined; var typeTag = ts.getJSDocTypeTag(node); - var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); - return signature && getErasedSignature(signature); + return (typeTag === null || typeTag === void 0 ? void 0 : typeTag.typeExpression) && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); } function getReturnTypeOfTypeTag(node) { var signature = getSignatureOfTypeTag(node); @@ -54600,14 +55943,14 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return node.name.kind === 158 /* ComputedPropertyName */ + case 164 /* PropertyDeclaration */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + return node.name.kind === 159 /* ComputedPropertyName */ && traverse(node.name); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: return traverse(node.expression); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -54615,7 +55958,7 @@ var ts; } } function getSignaturesOfSymbol(symbol) { - if (!symbol) + if (!symbol || !symbol.declarations) return ts.emptyArray; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { @@ -54656,8 +55999,8 @@ var ts; var targetTypePredicate = getTypePredicateOfSignature(signature.target); signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate; } - else if (signature.unionSignatures) { - signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate; + else if (signature.compositeSignatures) { + signature.resolvedTypePredicate = getUnionOrIntersectionTypePredicate(signature.compositeSignatures, signature.compositeKind) || noTypePredicate; } else { var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); @@ -54679,17 +56022,20 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 187 /* ThisType */ ? + return parameterName.kind === 188 /* 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); } + function getUnionOrIntersectionType(types, kind, unionReduction) { + return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.unionSignatures ? instantiateType(getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); if (signature.flags & 8 /* IsInnerCallChain */) { @@ -54722,7 +56068,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 166 /* Constructor */) { + if (declaration.kind === 167 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -54732,12 +56078,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 167 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 168 /* GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 168 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 169 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -54814,9 +56160,20 @@ var ts; function getBaseSignature(signature) { var typeParameters = signature.typeParameters; if (typeParameters) { - var typeEraser_1 = createTypeEraser(typeParameters); - var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; }); - return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); + if (signature.baseSignatureCache) { + return signature.baseSignatureCache; + } + var typeEraser = createTypeEraser(typeParameters); + var baseConstraintMapper_1 = createTypeMapper(typeParameters, ts.map(typeParameters, function (tp) { return getConstraintOfTypeParameter(tp) || unknownType; })); + var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(tp, baseConstraintMapper_1) || unknownType; }); + // Run N type params thru the immediate constraint mapper up to N times + // This way any noncircular interdependent type parameters are definitely resolved to their external dependencies + for (var i = 0; i < typeParameters.length - 1; i++) { + baseConstraints = instantiateTypes(baseConstraints, baseConstraintMapper_1); + } + // and then apply a type eraser to remove any remaining circularly dependent type parameters + baseConstraints = instantiateTypes(baseConstraints, typeEraser); + return signature.baseSignatureCache = instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), /*eraseTypeParameters*/ true); } return signature; } @@ -54827,7 +56184,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 === 166 /* Constructor */ || kind === 170 /* ConstructSignature */ || kind === 175 /* ConstructorType */; + var isConstructor = kind === 167 /* Constructor */ || kind === 171 /* ConstructSignature */ || kind === 176 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -54838,12 +56195,22 @@ var ts; return signature.isolatedSignatureType; } function getIndexSymbol(symbol) { - return symbol.members.get("__index" /* Index */); + return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; + } + function getIndexSymbolFromSymbolTable(symbolTable) { + return symbolTable.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { + var indexSymbol = symbol && getIndexSymbol(symbol); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfSymbolTable(symbolTable, kind) { + var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable); + return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind); + } + function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) { var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */; - var indexSymbol = getIndexSymbol(symbol); - if (indexSymbol) { + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = ts.cast(decl, ts.isIndexSignatureDeclaration); @@ -54871,17 +56238,18 @@ var ts; return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; } function getInferredTypeParameterConstraint(typeParameter) { + var _a; var inferences; - if (typeParameter.symbol) { - for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (declaration.parent.kind === 185 /* InferType */) { + if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { + for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (declaration.parent.kind === 186 /* InferType */) { // 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 _b = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _c = _b[0], childTypeParameter = _c === void 0 ? declaration.parent : _c, grandParent = _b[1]; - if (grandParent.kind === 173 /* TypeReference */) { + var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; + if (grandParent.kind === 174 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -54906,21 +56274,32 @@ 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 === 160 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 181 /* RestType */ || - grandParent.kind === 192 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 161 /* Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 182 /* RestType */ || + grandParent.kind === 193 /* 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 === 194 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 195 /* 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 === 159 /* TypeParameter */ && grandParent.parent.kind === 190 /* MappedType */) { + else if (grandParent.kind === 160 /* TypeParameter */ && grandParent.parent.kind === 191 /* MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } + // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends + // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template + // of the check type's mapped type + else if (grandParent.kind === 191 /* MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 185 /* ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 191 /* MappedType */ && + grandParent.parent.checkType.type) { + var checkMappedType_1 = grandParent.parent.checkType; + var nodeType = getTypeFromTypeNode(checkMappedType_1.type); + inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType))); + } } } } @@ -54943,7 +56322,7 @@ var ts; if (type.flags & 1 /* Any */ && type !== errorType) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 190 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 191 /* MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -54952,7 +56331,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 159 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 160 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -54994,7 +56373,7 @@ var ts; result |= ts.getObjectFlags(type); } } - return result & 3670016 /* PropagatingFlags */; + return result & 917504 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -55038,8 +56417,8 @@ var ts; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 173 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 174 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 179 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -55081,7 +56460,7 @@ var ts; return errorType; } } - if (node.kind === 173 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 174 /* 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 @@ -55123,16 +56502,26 @@ var ts; ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } + // We refrain from associating a local type alias with an instantiation of a top-level type alias + // because the local alias may end up being referenced in an inferred return type where it is not + // accessible--which in turn may lead to a large structural expansion of the type when generating + // a .d.ts file. See #43622 for an example. var aliasSymbol = getAliasSymbolForTypeNode(node); - return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + var newAliasSymbol = aliasSymbol && (isLocalTypeAlias(symbol) || !isLocalTypeAlias(aliasSymbol)) ? aliasSymbol : undefined; + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), newAliasSymbol, getTypeArgumentsForAliasSymbol(newAliasSymbol)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } + function isLocalTypeAlias(symbol) { + var _a; + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias); + return !!(declaration && ts.getContainingFunction(declaration)); + } function getTypeReferenceName(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 174 /* TypeReference */: return node.typeName; - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -55188,7 +56577,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 195 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 196 /* 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); @@ -55214,7 +56603,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 179 /* TupleType */ && node.elements.length === 1; + return node.kind === 180 /* TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -55223,9 +56612,17 @@ var ts; } function getConditionalFlowTypeOfType(type, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 311 /* JSDocComment */) { + var covariant = true; + while (node && !ts.isStatement(node) && node.kind !== 312 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 184 /* ConditionalType */ && node === parent.trueType) { + // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but + // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax + if (parent.kind === 161 /* Parameter */) { + covariant = !covariant; + } + // Always substitute on type parameters, regardless of variance, since even + // in contravariant positions, they may rely on substituted constraints to be valid + if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 185 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -55236,7 +56633,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 173 /* TypeReference */ || node.kind === 195 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 174 /* TypeReference */ || node.kind === 196 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -55346,13 +56743,15 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { - var declaration = declarations_3[_i]; - switch (declaration.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - return declaration; + if (declarations) { + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; + switch (declaration.kind) { + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 256 /* EnumDeclaration */: + return declaration; + } } } } @@ -55396,6 +56795,9 @@ var ts; function getGlobalESSymbolConstructorSymbol(reportErrors) { return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); } + function getGlobalESSymbolConstructorTypeSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorTypeSymbol || (deferredGlobalESSymbolConstructorTypeSymbol = getGlobalTypeSymbol("SymbolConstructor", reportErrors)); + } function getGlobalESSymbolType(reportErrors) { return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors)) || emptyObjectType; } @@ -55472,11 +56874,11 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 180 /* OptionalType */: + case 181 /* OptionalType */: return 2 /* Optional */; - case 181 /* RestType */: + case 182 /* RestType */: return getRestTypeElementFlags(node); - case 192 /* NamedTupleMember */: + case 193 /* NamedTupleMember */: return node.questionToken ? 2 /* Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : 1 /* Required */; @@ -55494,14 +56896,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 !== 192 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 193 /* 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 === 178 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 179 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 179 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 180 /* 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 @@ -55510,18 +56912,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 189 /* IndexedAccessType */: - case 184 /* ConditionalType */: - case 188 /* TypeOperator */: - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 187 /* ParenthesizedType */: + case 193 /* NamedTupleMember */: + case 174 /* TypeReference */: + case 183 /* UnionType */: + case 184 /* IntersectionType */: + case 190 /* IndexedAccessType */: + case 185 /* ConditionalType */: + case 189 /* TypeOperator */: + case 179 /* ArrayType */: + case 180 /* TupleType */: return isResolvedByTypeAlias(parent); - case 254 /* TypeAliasDeclaration */: + case 255 /* TypeAliasDeclaration */: return true; } return false; @@ -55530,28 +56932,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 173 /* TypeReference */: + case 174 /* TypeReference */: return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 176 /* TypeQuery */: + case 177 /* TypeQuery */: return true; - case 188 /* TypeOperator */: + case 189 /* TypeOperator */: return node.operator !== 151 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 192 /* NamedTupleMember */: - case 307 /* JSDocOptionalType */: - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 187 /* ParenthesizedType */: + case 181 /* OptionalType */: + case 193 /* NamedTupleMember */: + case 308 /* JSDocOptionalType */: + case 306 /* JSDocNullableType */: + case 307 /* JSDocNonNullableType */: + case 302 /* JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 181 /* RestType */: - return node.type.kind !== 178 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 182 /* RestType */: + return node.type.kind !== 179 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 183 /* UnionType */: + case 184 /* IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 189 /* IndexedAccessType */: + case 190 /* IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 184 /* ConditionalType */: + case 185 /* ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -55564,12 +56966,12 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 179 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 179 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 180 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 180 /* TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 178 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 179 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } @@ -55813,7 +57215,7 @@ var ts; if (type === wildcardType) includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 524288 /* ContainsWideningType */)) + if (!(ts.getObjectFlags(type) & 131072 /* ContainsWideningType */)) includes |= 4194304 /* IncludesNonWideningType */; } else { @@ -55836,6 +57238,11 @@ var ts; return includes; } function removeSubtypes(types, hasObjectTypes) { + var id = getTypeListId(types); + var match = subtypeReductionCache.get(id); + if (match) { + return match; + } // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. @@ -55847,6 +57254,13 @@ var ts; i--; var source = types[i]; if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + // Find the first property with a unit type, if any. When constituents have a property by the same name + // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype + // reduction of large discriminated union types. + var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : + undefined; + var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var target = types_11[_i]; if (source !== target) { @@ -55859,10 +57273,16 @@ var ts; if (estimatedCount > 1000000) { ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); - return false; + return undefined; } } count++; + if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); + if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { + continue; + } + } if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || isTypeDerivedFrom(source, target))) { @@ -55873,7 +57293,8 @@ var ts; } } } - return true; + subtypeReductionCache.set(id, types); + return types; } function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) { var i = types.length; @@ -55951,16 +57372,15 @@ var ts; if (includes & 3 /* AnyOrUnknown */) { return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType; } - if (unionReduction & (1 /* Literal */ | 2 /* Subtype */)) { - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); - } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { - removeStringLiteralsMatchedByTemplateLiterals(typeSet); - } + if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + } + if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction & 2 /* Subtype */) { - if (!removeSubtypes(typeSet, !!(includes & 524288 /* Object */))) { + if (unionReduction === 2 /* Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (!typeSet) { return errorType; } } @@ -55997,18 +57417,23 @@ var ts; origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); } } - var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 262144 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 268435456 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 468598819 /* NotPrimitiveUnion */ ? 0 : 65536 /* PrimitiveUnion */) | + (includes & 2097152 /* Intersection */ ? 67108864 /* ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } - function getUnionTypePredicate(signatures) { + function getUnionOrIntersectionTypePredicate(signatures, kind) { var first; var types = []; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - continue; + if (kind !== 2097152 /* Intersection */) { + continue; + } + else { + return; // intersections demand all members be type predicates for the result to have a predicate + } } if (first) { if (!typePredicateKindsMatch(first, pred)) { @@ -56022,11 +57447,11 @@ var ts; types.push(pred.type); } if (!first) { - // No union signatures had a type predicate. + // No signatures had a type predicate. return undefined; } - var unionType = getUnionType(types); - return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); + var compositeType = getUnionOrIntersectionType(types, kind); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, compositeType); } function typePredicateKindsMatch(a, b) { return a.kind === b.kind && a.parameterIndex === b.parameterIndex; @@ -56051,7 +57476,7 @@ var ts; var typeKey = !origin ? getTypeListId(types) : origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id; + "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { @@ -56178,7 +57603,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */); }); if (index < 0) { return false; } @@ -56187,7 +57612,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 262144 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 65536 /* PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -56216,7 +57641,7 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 262144 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 65536 /* PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { @@ -56417,13 +57842,13 @@ var ts; function getLiteralTypeFromProperty(prop, include) { if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; - if (!type && !ts.isKnownSymbol(prop)) { + if (!type) { if (prop.escapedName === "default" /* Default */) { type = getLiteralType("default"); } else { var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration); - type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop)); + type = name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getLiteralType(ts.symbolName(prop)) : undefined); } } if (type && type.flags & include) { @@ -56554,10 +57979,8 @@ var ts; return type.flags & 128 /* StringLiteral */ ? type.value : type.flags & 256 /* NumberLiteral */ ? "" + type.value : type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & 512 /* BooleanLiteral */ ? type.intrinsicName : - type.flags & 65536 /* Null */ ? "null" : - type.flags & 32768 /* Undefined */ ? "undefined" : - undefined; + type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + undefined; } function createTemplateLiteralType(texts, types) { var type = createType(134217728 /* TemplateLiteral */); @@ -56616,7 +58039,7 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 16384 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 8192 /* JSLiteral */) { return true; } if (type.flags & 1048576 /* Union */) { @@ -56632,15 +58055,12 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : - accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? - ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : - accessNode && ts.isPropertyName(accessNode) ? - // late bound names are handled in the first branch, so here we only need to handle normal names - ts.getPropertyNameForPropertyNameNode(accessNode) : - undefined; + accessNode && ts.isPropertyName(accessNode) ? + // late bound names are handled in the first branch, so here we only need to handle normal names + ts.getPropertyNameForPropertyNameNode(accessNode) : + undefined; } function isUncalledFunctionReference(node, symbol) { if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { @@ -56654,17 +58074,17 @@ var ts; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) { var _a; - var accessExpression = accessNode && accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 203 /* ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { - if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { + if (reportDeprecated && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, isSelfTypeAccess(accessExpression.expression, objectType.symbol)); if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -56814,13 +58234,13 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 202 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 189 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 158 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 203 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 190 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 159 /* ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return templateConstraintType.types.indexOf(type) !== -1 || !!(type.flags & 1 /* Any */); + return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)); } function isPatternLiteralType(type) { return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); @@ -56833,6 +58253,13 @@ var ts; } return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 4194304 /* IsGenericObjectTypeComputed */)) { + type.objectFlags |= 4194304 /* IsGenericObjectTypeComputed */ | + (isGenericObjectType(type.substitute) || isGenericObjectType(type.baseType) ? 8388608 /* IsGenericObjectType */ : 0); + } + return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); + } return !!(type.flags & 58982400 /* InstantiableNonPrimitive */) || isGenericMappedType(type) || isGenericTupleType(type); } function isGenericIndexType(type) { @@ -56843,6 +58270,13 @@ var ts; } return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); } + if (type.flags & 33554432 /* Substitution */) { + if (!(type.objectFlags & 16777216 /* IsGenericIndexTypeComputed */)) { + type.objectFlags |= 16777216 /* IsGenericIndexTypeComputed */ | + (isGenericIndexType(type.substitute) || isGenericIndexType(type.baseType) ? 33554432 /* IsGenericIndexType */ : 0); + } + return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); + } return !!(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type); } function isThisTypeParameter(type) { @@ -56918,6 +58352,12 @@ 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; @@ -56988,7 +58428,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 !== 189 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 190 /* IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { if (objectType.flags & 3 /* AnyOrUnknown */) { @@ -57073,9 +58513,9 @@ var ts; } function isTypicalNondistributiveConditional(root) { return !root.isDistributive - && root.node.checkType.kind === 179 /* TupleType */ + && root.node.checkType.kind === 180 /* TupleType */ && ts.length(root.node.checkType.elements) === 1 - && root.node.extendsType.kind === 179 /* TupleType */ + && root.node.extendsType.kind === 180 /* TupleType */ && ts.length(root.node.extendsType.elements) === 1; } /** @@ -57094,7 +58534,7 @@ var ts; // purposes of resolution. This means such types aren't subject to the instatiation depth limiter. while (true) { var isUnwrapped = isTypicalNondistributiveConditional(root); - var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.checkType), mapper); + var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper); var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType); var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper); if (checkType === wildcardType || extendsType === wildcardType) { @@ -57107,9 +58547,12 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, extendsType, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, extendsType, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); } - combinedMapper = mergeTypeMappers(mapper, context.mapper); + // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the + // those type parameters are used in type references (see getInferredTypeParameterConstraint). For + // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples. + combinedMapper = mapper ? combineTypeMappers(context.mapper, mapper) : context.mapper; } // Instantiate the extends type including inferences for 'infer T' type parameters var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType; @@ -57361,7 +58804,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0 /* String */), getIndexInfoOfType(type, 1 /* Number */)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return spread; } } @@ -57467,14 +58910,15 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */ | 1024 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */ | 4194304 /* ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { - return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) && + var _a; + return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || - !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); })); + !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); @@ -57562,7 +59006,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 === 253 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 254 /* InterfaceDeclaration */)) { if (!ts.hasSyntacticModifier(container, 32 /* Static */) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; @@ -57597,17 +59041,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 187 /* ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 179 /* TupleType */: + case 180 /* TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 181 /* RestType */ || node.kind === 192 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 182 /* RestType */ || node.kind === 193 /* NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 178 /* ArrayType */: + case 179 /* ArrayType */: return node.elementType; } return undefined; @@ -57625,8 +59069,8 @@ var ts; function getTypeFromTypeNodeWorker(node) { switch (node.kind) { case 128 /* AnyKeyword */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 304 /* JSDocAllType */: + case 305 /* JSDocUnknownType */: return anyType; case 152 /* UnknownKeyword */: return unknownType; @@ -57653,70 +59097,70 @@ var ts; return node.flags & 131072 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; case 136 /* IntrinsicKeyword */: return intrinsicMarkerType; - case 187 /* ThisType */: + case 188 /* ThisType */: case 107 /* 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 191 /* LiteralType */: + case 192 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 173 /* TypeReference */: + case 174 /* TypeReference */: return getTypeFromTypeReference(node); - case 172 /* TypePredicate */: + case 173 /* TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 176 /* TypeQuery */: + case 177 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 179 /* ArrayType */: + case 180 /* TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 180 /* OptionalType */: + case 181 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 182 /* UnionType */: + case 183 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 183 /* IntersectionType */: + case 184 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 305 /* JSDocNullableType */: + case 306 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 307 /* JSDocOptionalType */: + case 308 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 192 /* NamedTupleMember */: + case 193 /* NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 186 /* ParenthesizedType */: - case 306 /* JSDocNonNullableType */: - case 301 /* JSDocTypeExpression */: + case 187 /* ParenthesizedType */: + case 307 /* JSDocNonNullableType */: + case 302 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 181 /* RestType */: + case 182 /* RestType */: return getTypeFromRestTypeNode(node); - case 309 /* JSDocVariadicType */: + case 310 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 177 /* TypeLiteral */: - case 312 /* JSDocTypeLiteral */: - case 308 /* JSDocFunctionType */: - case 313 /* JSDocSignature */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: + case 178 /* TypeLiteral */: + case 314 /* JSDocTypeLiteral */: + case 309 /* JSDocFunctionType */: + case 315 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 188 /* TypeOperator */: + case 189 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 189 /* IndexedAccessType */: + case 190 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 190 /* MappedType */: + case 191 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 184 /* ConditionalType */: + case 185 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 185 /* InferType */: + case 186 /* InferType */: return getTypeFromInferTypeNode(node); - case 193 /* TemplateLiteralType */: + case 194 /* TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 195 /* ImportType */: + case 196 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. case 78 /* Identifier */: - case 157 /* QualifiedName */: - case 201 /* PropertyAccessExpression */: + case 158 /* QualifiedName */: + case 202 /* PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -57886,8 +59330,9 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? - ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration); }) : + var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; } @@ -57917,9 +59362,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 157 /* QualifiedName */ || - node.parent.kind === 173 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 195 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.kind === 158 /* QualifiedName */ || + node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -57928,22 +59373,25 @@ 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 === 230 /* Block */ || n.kind === 184 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 231 /* Block */ || n.kind === 185 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } - return !!ts.forEachChild(node, containsReference); + return containsReference(node); } return true; function containsReference(node) { switch (node.kind) { - case 187 /* ThisType */: + case 188 /* ThisType */: return !!tp.isThisType; case 78 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 176 /* TypeQuery */: + case 177 /* TypeQuery */: return true; + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); } return !!ts.forEachChild(node, containsReference); } @@ -58123,6 +59571,9 @@ var ts; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } + if (objectFlags & 1024 /* ReverseMapped */) { + return instantiateReverseMappedType(type, mapper); + } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; @@ -58172,6 +59623,21 @@ var ts; } return type; } + function instantiateReverseMappedType(type, mapper) { + var innerMappedType = instantiateType(type.mappedType, mapper); + if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + return type; + } + var innerIndexType = instantiateType(type.constraintType, mapper); + if (!(innerIndexType.flags & 4194304 /* Index */)) { + return type; + } + var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); + if (instantiated) { + return instantiated; + } + return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable + } function getPermissiveInstantiation(type) { return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); @@ -58198,35 +59664,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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 166 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 166 /* MethodDeclaration */: + case 252 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 281 /* JsxAttributes */: + case 282 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 280 /* JsxAttribute */: { + case 281 /* 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 283 /* JsxExpression */: { + case 284 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -58245,7 +59711,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 209 /* ArrowFunction */) { + if (node.kind !== 210 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -58258,7 +59724,7 @@ 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 !== 230 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 231 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -58361,23 +59827,23 @@ var ts; return true; } switch (node.kind) { - case 283 /* JsxExpression */: - case 207 /* ParenthesizedExpression */: + case 284 /* JsxExpression */: + case 208 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: switch (node.operatorToken.kind) { case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 281 /* JsxAttributes */: + case 282 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -58577,7 +60043,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -58586,9 +60052,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: - case 277 /* JsxFragment */: + case 274 /* JsxElement */: + case 275 /* JsxSelfClosingElement */: + case 278 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -58736,11 +60202,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 168 /* SetAccessor */: return [3 /*break*/, 2]; - case 167 /* GetAccessor */: return [3 /*break*/, 2]; - case 165 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 289 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 288 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 169 /* SetAccessor */: return [3 /*break*/, 2]; + case 168 /* GetAccessor */: return [3 /*break*/, 2]; + case 166 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 290 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 289 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -58817,8 +60283,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 165 /* MethodDeclaration */ && - kind !== 164 /* MethodSignature */ && kind !== 166 /* Constructor */; + var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 166 /* MethodDeclaration */ && + kind !== 165 /* MethodSignature */ && kind !== 167 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -59051,7 +60517,7 @@ var ts; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) return true; } return false; @@ -59088,7 +60554,7 @@ var ts; return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { @@ -59098,6 +60564,7 @@ var ts; type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : type; + t = getSingleBaseForNonAugmentingSubtype(t) || t; if (t === type) break; type = t; @@ -59271,6 +60738,14 @@ var ts; } break; } + case ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target, args[0], args[1]]); + break; + } + case ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target.code: { + secondaryRootErrors.unshift([ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, args[0], args[1], args[2]]); + break; + } default: return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); } @@ -59331,6 +60806,7 @@ var ts; reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, needsOriginalSource ? sourceType : generalizedSourceType, targetType, typeToString(constraint)); } else { + errorInfo = undefined; reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, generalizedSourceType); } } @@ -59406,7 +60882,7 @@ var ts; if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { return -1 /* True */; } - reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 4096 /* JsxAttributes */)); + reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 2048 /* JsxAttributes */)); return 0 /* False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, @@ -59441,16 +60917,16 @@ var ts; target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { - if (source === nullStrippedTarget) - return -1 /* True */; - target = nullStrippedTarget; + target = getNormalizedType(nullStrippedTarget, /*writing*/ true); } + if (source === nullStrippedTarget) + return -1 /* True */; } if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768 /* FreshLiteral */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 16384 /* FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { @@ -59535,7 +61011,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. 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) & 2097152 /* NonInferrableType */); }))) { + 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 */); inPropertyCheck = false; @@ -59544,8 +61020,10 @@ var ts; return result; function reportErrorResults(source, target, result, isComparingJsxAttributes) { if (!result && reportErrors) { - source = originalSource.aliasSymbol ? originalSource : source; - target = originalTarget.aliasSymbol ? originalTarget : target; + var sourceHasBase = !!getSingleBaseForNonAugmentingSubtype(originalSource); + var targetHasBase = !!getSingleBaseForNonAugmentingSubtype(originalTarget); + source = (originalSource.aliasSymbol || sourceHasBase) ? originalSource : source; + target = (originalTarget.aliasSymbol || targetHasBase) ? originalTarget : target; var maybeSuppress = overrideNextErrorInfo > 0; if (maybeSuppress) { overrideNextErrorInfo--; @@ -59592,7 +61070,7 @@ var ts; if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 262144 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 65536 /* PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } @@ -59617,11 +61095,11 @@ var ts; } traceUnionsOrIntersectionsTooLarge(source, target); if (flags & 3145728 /* UnionOrIntersection */) { - var result_6 = eachTypeRelatedToSomeType(source, target); - if (result_6) { - result_6 &= eachTypeRelatedToSomeType(target, source); + var result_7 = eachTypeRelatedToSomeType(source, target); + if (result_7) { + result_7 &= eachTypeRelatedToSomeType(target, source); } - return result_6; + return result_7; } return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */); } @@ -59635,10 +61113,11 @@ var ts; return getUnionType(ts.reduceLeft(types, appendPropType, /*initial*/ undefined) || ts.emptyArray); } function hasExcessProperties(source, target, reportErrors) { - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384 /* JSLiteral */) { + var _a; + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 8192 /* JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; @@ -59681,7 +61160,7 @@ var ts; } else { // use the property's value declaration if the property is assigned inside the literal itself - var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var objectLiteralDeclaration_1 = ((_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) && ts.firstOrUndefined(source.symbol.declarations); var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) { var propDeclaration = prop.valueDeclaration; @@ -59710,8 +61189,8 @@ var ts; } } }; - for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { - var prop = _a[_i]; + for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { + var prop = _b[_i]; var state_5 = _loop_16(prop); if (typeof state_5 === "object") return state_5.value; @@ -59736,8 +61215,17 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */ && containsType(targetTypes, source)) { - return -1 /* True */; + if (target.flags & 1048576 /* Union */) { + if (containsType(targetTypes, source)) { + return -1 /* True */; + } + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + var related = isRelatedTo(source, match, /*reportErrors*/ false); + if (related) { + return related; + } + } } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; @@ -59911,9 +61399,16 @@ var ts; targetStack = []; } else { + // generate a key where all type parameter id positions are replaced with unconstrained type parameter ids + // this isn't perfect - nested type references passed as type arguments will muck up the indexes and thus + // prevent finding matches- but it should hit up the common cases + var broadestEquivalentId = id.split(",").map(function (i) { return i.replace(/-\d+/g, function (_match, offset) { + var index = ts.length(id.slice(0, offset).match(/[-=]/g) || undefined); + return "=" + index; + }); }).join(","); for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions - if (id === maybeKeys[i]) { + if (id === maybeKeys[i] || broadestEquivalentId === maybeKeys[i]) { return 3 /* Maybe */; } } @@ -60002,8 +61497,21 @@ var ts; if (target.flags & 2097152 /* Intersection */) { return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); } - // Source is an intersection. Check to see if any constituents of the intersection are immediately related - // to the target. + // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the + // constraints of all non-primitive types in the source into a new intersection. We do this because the + // intersection may further constrain the constraints of the non-primitive types. For example, given a type + // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't + // appear to be comparable to '2'. + if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + var constraints = ts.sameMap(source.types, function (t) { return t.flags & 131068 /* Primitive */ ? t : getBaseConstraintOfType(t) || unknownType; }); + if (constraints !== source.types) { + source = getIntersectionType(constraints); + if (!(source.flags & 2097152 /* Intersection */)) { + return isRelatedTo(source, target, /*reportErrors*/ false); + } + } + } + // Check to see if any constituents of the intersection are immediately related to the target. // // Don't report errors though. Checking whether a constituent is related to the source is not actually // useful and leads to some confusing error messages. Instead it is better to let the below checks @@ -60023,21 +61531,21 @@ var ts; if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } - var result_7 = 0 /* False */; + var result_8 = 0 /* False */; if (flags & 8388608 /* IndexedAccess */) { - if (result_7 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { - return result_7; + if (result_8 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { + if (result_8 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { + return result_8; } } } if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result_7 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { - if (result_7 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { - return result_7; + 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)) { + return result_8; } } } @@ -60117,6 +61625,20 @@ var ts; } } else if (target.flags & 8388608 /* IndexedAccess */) { + 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) { + resetErrorInfo(saveErrorInfo); + return result; + } + if (reportErrors) { + originalErrorInfo = errorInfo; + } + } // A type S is related to a type T[K] if S is related to C, where C is the base // constraint of T[K] for writing. if (relation === assignableRelation || relation === comparableRelation) { @@ -60127,11 +61649,24 @@ var ts; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { var accessFlags = 2 /* Writing */ | (baseObjectType !== objectType ? 1 /* NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, accessFlags); - if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) { - return result; + if (constraint) { + if (reportErrors && originalErrorInfo) { + // create a new chain for the constraint error + resetErrorInfo(saveErrorInfo); + } + if (result = isRelatedTo(source, constraint, reportErrors)) { + return result; + } + // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain + if (reportErrors && originalErrorInfo && errorInfo) { + errorInfo = countMessageChainBreadth([originalErrorInfo]) <= countMessageChainBreadth([errorInfo]) ? originalErrorInfo : errorInfo; + } } } } + if (reportErrors) { + originalErrorInfo = undefined; + } } else if (isGenericMappedType(target) && !target.declaration.nameType) { // A source type T is related to a target type { [P in X]: T[P] } @@ -60175,27 +61710,48 @@ var ts; } } } - else if (target.flags & 134217728 /* TemplateLiteral */ && source.flags & 128 /* StringLiteral */) { - if (isPatternLiteralType(target)) { - // match all non-`string` segments - var result_8 = inferLiteralsFromTemplateLiteralType(source, target); - if (result_8 && ts.every(result_8, function (r, i) { return isStringLiteralTypeValueParsableAsType(r, target.types[i]); })) { - return -1 /* True */; - } + 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) { + resetErrorInfo(saveErrorInfo); + return localResult; } } - if (source.flags & 8650752 /* TypeVariable */) { - if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { - // 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) { - resetErrorInfo(saveErrorInfo); - return result; - } + else if (target.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TemplateLiteral */) { + // 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)); } - else { + var result_9 = inferTypesFromTemplateLiteralType(source, target); + if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) { + return -1 /* True */; + } + } + if (source.flags & 8650752 /* TypeVariable */) { + // IndexedAccess comparisons are handled above in the `target.flags & TypeFlage.IndexedAccess` branch + if (!(source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */)) { 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. @@ -60210,7 +61766,7 @@ var ts; 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, /*headMessage*/ undefined, intersectionState)) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -60223,17 +61779,13 @@ var ts; } } else if (source.flags & 134217728 /* TemplateLiteral */) { - if (target.flags & 134217728 /* TemplateLiteral */ && - source.texts.length === target.texts.length && - source.types.length === target.types.length && - ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) && - ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 /* Any */ | 4 /* String */)) || !!isRelatedTo(t, target.types[i], /*reportErrors*/ false); })) { - return -1 /* True */; - } - var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) { - resetErrorInfo(saveErrorInfo); - return result; + if (!(target.flags & 134217728 /* TemplateLiteral */)) { + var baseConstraint = getBaseConstraintOfType(source); + var constraint = baseConstraint && baseConstraint !== source ? baseConstraint : stringType; + if (result = isRelatedTo(constraint, target, reportErrors)) { + resetErrorInfo(saveErrorInfo); + return result; + } } } else if (source.flags & 268435456 /* StringMapping */) { @@ -60262,7 +61814,7 @@ var ts; 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); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 256 /* NoConstraints */ | 512 /* AlwaysStrict */); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } @@ -60320,7 +61872,7 @@ var ts; return 0 /* False */; } if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && - !(ts.getObjectFlags(source) & 8192 /* MarkerType */ || ts.getObjectFlags(target) & 8192 /* MarkerType */)) { + !(ts.getObjectFlags(source) & 4096 /* MarkerType */ || ts.getObjectFlags(target) & 4096 /* MarkerType */)) { // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. @@ -60348,7 +61900,7 @@ var ts; } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 32768 /* FreshLiteral */ && !isEmptyObjectType(source)) { + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 16384 /* FreshLiteral */ && !isEmptyObjectType(source)) { return 0 /* False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, @@ -60386,14 +61938,19 @@ 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_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); - if (result_9) { - return result_9; + var result_10 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); + if (result_10) { + return result_10; } } } } return 0 /* False */; + function countMessageChainBreadth(info) { + if (!info) + return 0; + return ts.reduceLeft(info, function (value, chain) { return value + 1 + countMessageChainBreadth(chain.next); }, 0); + } function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) { if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; @@ -60455,13 +62012,13 @@ var ts; var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { - var result_10; + var result_11; var targetConstraint = getConstraintTypeFromMappedType(target); var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { + if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); + return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } } @@ -60601,7 +62158,7 @@ var ts; ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); - var result_11 = unionParent ? 0 /* False */ : -1 /* True */; + var result_12 = unionParent ? 0 /* False */ : -1 /* True */; var targetTypes = links.deferralConstituents; for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { var targetType = targetTypes_3[_i]; @@ -60611,7 +62168,7 @@ var ts; // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); } - result_11 &= related; + result_12 &= related; } else { if (related) { @@ -60619,17 +62176,17 @@ var ts; } } } - if (unionParent && !result_11 && targetIsOptional) { - result_11 = isRelatedTo(source, undefinedType); + if (unionParent && !result_12 && targetIsOptional) { + result_12 = isRelatedTo(source, undefinedType); } - if (unionParent && !result_11 && reportErrors) { + if (unionParent && !result_12 && reportErrors) { // The easiest way to get the right errors here is to un-defer (which may be costly) // If it turns out this is too costly too often, we can replicate the error handling logic within // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union // type on which to hand discriminable properties, which we are expressly trying to avoid here) return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); } - return result_11; + return result_12; } else { return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState); @@ -60960,7 +62517,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) === 166 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 166 /* Constructor */)) { + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 167 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 167 /* Constructor */)) { var constructSignatureToString = function (signature) { return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); }; @@ -61068,10 +62625,17 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetType = getIndexTypeOfType(target, kind); - if (!targetType || targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { - // Index signature of type any permits assignment from everything but primitives + if (!targetType) { return -1 /* True */; } + if (targetType.flags & 1 /* Any */ && !sourceIsPrimitive) { + // An index signature of type `any` permits assignment from everything but primitives, + // provided that there is also a `string` index signature of type `any`. + var stringIndexType = kind === 0 /* String */ ? targetType : getIndexTypeOfType(target, 0 /* String */); + if (stringIndexType && stringIndexType.flags & 1 /* Any */) { + return -1 /* True */; + } + } if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to a type with an index signature // { [x: string]: U }, and optionally with an index signature { [x: number]: V }, @@ -61226,7 +62790,7 @@ var ts; // type, and flag the result as a marker type reference. function getMarkerTypeReference(type, source, target) { var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; })); - result.objectFlags |= 8192 /* MarkerType */; + result.objectFlags |= 4096 /* MarkerType */; return result; } function getAliasVariances(symbol) { @@ -61314,7 +62878,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -61400,8 +62964,8 @@ var ts; } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. - function isClassDerivedFromDeclaringClasses(checkClass, prop) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 /* Protected */ ? + function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -61419,23 +62983,26 @@ var ts; function isDeeplyNestedType(type, stack, depth) { if (depth >= 5) { var identity_1 = getRecursionIdentity(type); - if (identity_1) { - var count = 0; - for (var i = 0; i < depth; i++) { - if (getRecursionIdentity(stack[i]) === identity_1) { - count++; - if (count >= 5) { - return true; - } + var count = 0; + for (var i = 0; i < depth; i++) { + if (getRecursionIdentity(stack[i]) === identity_1) { + count++; + if (count >= 5) { + return true; } } } } return false; } - // Types with constituents that could circularly reference the type have a recursion identity. The recursion - // identity is some object that is common to instantiations of the type with the same origin. + // The recursion identity of a type is an object identity that is shared among multiple instantiations of the type. + // We track recursion identities in order to identify deeply nested and possibly infinite type instantiations with + // the same origin. For example, when type parameters are in scope in an object type such as { x: T }, all + // instantiations of that type have the same recursion identity. The default recursion identity is the object + // identity of the type, meaning that every type is unique. Generally, types with constituents that could circularly + // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { + // Object and array literals are known not to contain recursive references and don't need a recursion identity. if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer @@ -61453,6 +63020,9 @@ var ts; return type.target; } } + if (type.flags & 262144 /* TypeParameter */) { + return type.symbol; + } if (type.flags & 8388608 /* IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { @@ -61464,7 +63034,7 @@ var ts; // The root object represents the origin of the conditional type return type.root; } - return undefined; + return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; @@ -61603,6 +63173,9 @@ var ts; // of those literal types. Otherwise, return the leftmost type for which no type to the // right is a supertype. function getSupertypeOrUnion(types) { + if (types.length === 1) { + return types[0]; + } return literalTypesWithSameBaseType(types) ? getUnionType(types) : ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); @@ -61637,9 +63210,32 @@ var ts; // or if it is not the undefined or null type and if it is assignable to ReadonlyArray return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } + function getSingleBaseForNonAugmentingSubtype(type) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + return undefined; + } + if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + } + type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + var target = type.target; + var bases = getBaseTypes(target); + if (bases.length !== 1) { + return undefined; + } + if (getMembersOfSymbol(type.symbol).size) { + return undefined; // If the interface has any members, they may subtype members in the base, so we should do a full structural comparison + } + var instantiatedBase = !ts.length(target.typeParameters) ? bases[0] : instantiateType(bases[0], createTypeMapper(target.typeParameters, getTypeArguments(type).slice(0, target.typeParameters.length))); + if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { + instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); + } + type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + return type.cachedEquivalentBaseType = instantiatedBase; + } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; - return elementType === undefinedWideningType || elementType === implicitNeverType; + var elementType = getElementTypeOfArrayType(type); + return strictNullChecks ? elementType === implicitNeverType : elementType === undefinedWideningType; } function isTupleLikeType(type) { return isTupleType(type) || !!getPropertyOfType(type, "0"); @@ -61663,6 +63259,13 @@ var ts; function isUnitType(type) { return !!(type.flags & 109440 /* Unit */); } + function isUnitLikeType(type) { + return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* Unit */); + } + function extractUnitType(type) { + return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + } function isLiteralType(type) { return type.flags & 16 /* Boolean */ ? true : type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : @@ -61813,14 +63416,17 @@ var ts; return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { + // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates + // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null' + // that isn't eliminated by a NonNullable instantiation. + var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); if (!deferredGlobalNonNullableTypeAlias) { deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } - // Use NonNullable global type alias if available to improve quick info/declaration emit - if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) { - return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]); - } - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior + // If the NonNullable type is available, return an instantiation. Otherwise just return the reduced type. + return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? + getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) : + reducedType; } function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; @@ -61873,7 +63479,7 @@ var ts; function isObjectTypeWithInferableIndex(type) { return type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -61906,7 +63512,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 16384 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -61917,7 +63523,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~32768 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~16384 /* FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -61947,7 +63553,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 1024 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 4194304 /* ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -61996,14 +63602,14 @@ var ts; var stringIndexInfo = getIndexInfoOfType(type, 0 /* String */); var numberIndexInfo = getIndexInfoOfType(type, 1 /* Number */); var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); - result.objectFlags |= (ts.getObjectFlags(type) & (16384 /* JSLiteral */ | 2097152 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (8192 /* JSLiteral */ | 524288 /* NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 1572864 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 393216 /* RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } @@ -62048,7 +63654,7 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(type) & 131072 /* ContainsWideningType */) { if (type.flags & 1048576 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; @@ -62074,7 +63680,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 524288 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 131072 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -62093,12 +63699,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 216 /* BinaryExpression */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 217 /* BinaryExpression */: + case 164 /* PropertyDeclaration */: + case 163 /* 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 160 /* Parameter */: + case 161 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -62113,23 +63719,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 198 /* BindingElement */: + case 199 /* 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 308 /* JSDocFunctionType */: + case 309 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 252 /* FunctionDeclaration */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 209 /* FunctionExpression */: + case 210 /* 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); @@ -62143,7 +63749,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 190 /* MappedType */: + case 191 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -62154,7 +63760,7 @@ var ts; errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type, wideningKind) { - if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 131072 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -62270,23 +63876,23 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 67108864 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); + if (objectFlags & 1048576 /* CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 2097152 /* CouldContainTypeVariables */); } var result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || - objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */)) || + objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); + type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 254 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 297 /* SourceFile */ ? true : n.kind === 256 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 255 /* TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 298 /* SourceFile */ ? true : n.kind === 257 /* ModuleDeclaration */ ? false : "quit"; })); } return false; } @@ -62339,7 +63945,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 2097152 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 524288 /* NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -62363,14 +63969,18 @@ var ts; } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(2048 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; return reversed; } function getTypeOfReverseMappedSymbol(symbol) { - return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + var links = getSymbolLinks(symbol); + if (!links.type) { + links.type = inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType); + } + return links.type; } function inferReverseMappedType(sourceType, target, constraint) { var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target)); @@ -62462,51 +64072,113 @@ var ts; // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */); } - function isStringLiteralTypeValueParsableAsType(s, target) { - if (target.flags & 1048576 /* Union */) { - return !!forEachType(target, function (t) { return isStringLiteralTypeValueParsableAsType(s, t); }); - } - switch (target) { - case stringType: return true; - case numberType: return s.value !== "" && isFinite(+(s.value)); - case bigintType: return s.value !== "" && isValidBigIntString(s.value); - // the next 4 should be handled in `getTemplateLiteralType`, as they are all exactly one value, but are here for completeness, just in case - // this function is ever used on types which don't come from template literal holes - case trueType: return s.value === "true"; - case falseType: return s.value === "false"; - case undefinedType: return s.value === "undefined"; - case nullType: return s.value === "null"; - default: return !!(target.flags & 1 /* Any */); - } - } - function inferLiteralsFromTemplateLiteralType(source, target) { - var value = source.value; - var texts = target.texts; - var lastIndex = texts.length - 1; - var startText = texts[0]; - var endText = texts[lastIndex]; - if (!(value.startsWith(startText) && value.slice(startText.length).endsWith(endText))) + function isValidTypeForTemplateLiteralPlaceholder(source, target) { + if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + return true; + } + if (source.flags & 128 /* StringLiteral */) { + var value = source.value; + return !!(target.flags & 8 /* Number */ && value !== "" && isFinite(+value) || + target.flags & 64 /* BigInt */ && value !== "" && isValidBigIntString(value) || + target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName); + } + if (source.flags & 134217728 /* TemplateLiteral */) { + var texts = source.texts; + return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); + } + return isTypeAssignableTo(source, target); + } + function inferTypesFromTemplateLiteralType(source, target) { + return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TemplateLiteral */ ? + ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : + inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : + undefined; + } + function getStringLikeTypeForType(type) { + return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + } + // This function infers from the text parts and type parts of a source literal to a target template literal. The number + // of text parts is always one more than the number of type parts, and a source string literal is treated as a source + // with one text part and zero type parts. The function returns an array of inferred string or template literal types + // corresponding to the placeholders in the target template literal, or undefined if the source doesn't match the target. + // + // We first check that the starting source text part matches the starting target text part, and that the ending source + // text part ends matches the ending target text part. We then iterate through the remaining target text parts, finding + // a match for each in the source and inferring string or template literal types created from the segments of the source + // that occur between the matches. During this iteration, seg holds the index of the current text part in the sourceTexts + // array and pos holds the current character position in the current text part. + // + // Consider inference from type `<<${string}>.<${number}-${number}>>` to type `<${string}.${string}>`, i.e. + // sourceTexts = ['<<', '>.<', '-', '>>'] + // sourceTypes = [string, number, number] + // target.texts = ['<', '.', '>'] + // We first match '<' in the target to the start of '<<' in the source and '>' in the target to the end of '>>' in + // the source. The first match for the '.' in target occurs at character 1 in the source text part at index 1, and thus + // the first inference is the template literal type `<${string}>`. The remainder of the source makes up the second + // inference, the template literal type `<${number}-${number}>`. + function inferFromLiteralPartsToTemplateLiteral(sourceTexts, sourceTypes, target) { + var lastSourceIndex = sourceTexts.length - 1; + var sourceStartText = sourceTexts[0]; + var sourceEndText = sourceTexts[lastSourceIndex]; + var targetTexts = target.texts; + var lastTargetIndex = targetTexts.length - 1; + var targetStartText = targetTexts[0]; + var targetEndText = targetTexts[lastTargetIndex]; + if (lastSourceIndex === 0 && sourceStartText.length < targetStartText.length + targetEndText.length || + !sourceStartText.startsWith(targetStartText) || !sourceEndText.endsWith(targetEndText)) return undefined; + var remainingEndText = sourceEndText.slice(0, sourceEndText.length - targetEndText.length); var matches = []; - var str = value.slice(startText.length, value.length - endText.length); - var pos = 0; - for (var i = 1; i < lastIndex; i++) { - var delim = texts[i]; - var delimPos = delim.length > 0 ? str.indexOf(delim, pos) : pos < str.length ? pos + 1 : -1; - if (delimPos < 0) + var seg = 0; + var pos = targetStartText.length; + for (var i = 1; i < lastTargetIndex; i++) { + var delim = targetTexts[i]; + if (delim.length > 0) { + var s = seg; + var p = pos; + while (true) { + p = getSourceText(s).indexOf(delim, p); + if (p >= 0) + break; + s++; + if (s === sourceTexts.length) + return undefined; + p = 0; + } + addMatch(s, p); + pos += delim.length; + } + else if (pos < getSourceText(seg).length) { + addMatch(seg, pos + 1); + } + else if (seg < lastSourceIndex) { + addMatch(seg + 1, 0); + } + else { return undefined; - matches.push(getLiteralType(str.slice(pos, delimPos))); - pos = delimPos + delim.length; + } } - matches.push(getLiteralType(str.slice(pos))); + addMatch(lastSourceIndex, getSourceText(lastSourceIndex).length); return matches; + function getSourceText(index) { + return index < lastSourceIndex ? sourceTexts[index] : remainingEndText; + } + function addMatch(s, p) { + var matchType = s === seg ? + getLiteralType(getSourceText(s).slice(pos, p)) : + getTemplateLiteralType(__spreadArray(__spreadArray([sourceTexts[seg].slice(pos)], sourceTexts.slice(seg + 1, s)), [getSourceText(s).slice(0, p)]), sourceTypes.slice(seg, s)); + matches.push(matchType); + seg = s; + pos = p; + } } function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) { if (priority === void 0) { priority = 0; } if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 1024 /* MaxValue */; + var inferencePriority = 2048 /* MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; @@ -62593,8 +64265,8 @@ var ts; // not contain anyFunctionType when we come back to this argument for its second round // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard // when constructing types from type parameters that had no inference candidates). - if (ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || - (priority & 64 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (ts.getObjectFlags(source) & 524288 /* NonInferrableType */ || source === nonInferrableAnyType || source === silentNeverType || + (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); @@ -62621,7 +64293,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 64 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -62661,7 +64333,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - inferWithPriority(empty, target.type, 128 /* LiteralKeyof */); + inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -62673,6 +64345,13 @@ var ts; inferFromTypes(source.type, target.type); } } + else if (source.flags & 33554432 /* Substitution */) { + inferFromTypes(source.baseType, target); + var oldPriority = priority; + priority |= 4 /* SubstituteSource */; + inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority + priority = oldPriority; + } else if (target.flags & 16777216 /* Conditional */) { invokeOnce(source, target, inferToConditionalType); } @@ -62692,7 +64371,7 @@ var ts; } else { source = getReducedType(source); - if (!(priority & 256 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` @@ -62730,26 +64409,22 @@ var ts; } (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; - var sourceIdentity = getRecursionIdentity(source) || source; - var targetIdentity = getRecursionIdentity(target) || target; - if (sourceIdentity && ts.contains(sourceStack, sourceIdentity)) + var sourceIdentity = getRecursionIdentity(source); + var targetIdentity = getRecursionIdentity(target); + if (ts.contains(sourceStack, sourceIdentity)) expandingFlags |= 1 /* Source */; - if (targetIdentity && ts.contains(targetStack, targetIdentity)) + if (ts.contains(targetStack, targetIdentity)) expandingFlags |= 2 /* Target */; if (expandingFlags !== 3 /* Both */) { - if (sourceIdentity) - (sourceStack || (sourceStack = [])).push(sourceIdentity); - if (targetIdentity) - (targetStack || (targetStack = [])).push(targetIdentity); + (sourceStack || (sourceStack = [])).push(sourceIdentity); + (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); - if (targetIdentity) - targetStack.pop(); - if (sourceIdentity) - sourceStack.pop(); + targetStack.pop(); + sourceStack.pop(); } else { inferencePriority = -1 /* Circularity */; @@ -62789,7 +64464,7 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 512 /* AlwaysStrict */) { + if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { contravariant = !contravariant; inferFromTypes(source, target); contravariant = !contravariant; @@ -62841,7 +64516,7 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 1024 /* MaxValue */; + inferencePriority = 2048 /* MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; @@ -62920,9 +64595,9 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 /* NonInferrableType */ ? - 8 /* PartialHomomorphicMappedType */ : - 4 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 524288 /* NonInferrableType */ ? + 16 /* PartialHomomorphicMappedType */ : + 8 /* HomomorphicMappedType */); } } return true; @@ -62930,7 +64605,7 @@ var ts; if (constraintType.flags & 262144 /* TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 16 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -62959,16 +64634,14 @@ var ts; } else { var savePriority = priority; - priority |= contravariant ? 32 /* ContravariantConditional */ : 0; + priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; inferToMultipleTypes(source, targetTypes, target.flags); priority = savePriority; } } function inferToTemplateLiteralType(source, target) { - var matches = source.flags & 128 /* StringLiteral */ ? inferLiteralsFromTemplateLiteralType(source, target) : - source.flags & 134217728 /* TemplateLiteral */ && ts.arraysEqual(source.texts, target.texts) ? source.types : - undefined; + var matches = inferTypesFromTemplateLiteralType(source, target); var types = target.types; for (var i = 0; i < types.length; i++) { inferFromTypes(matches ? matches[i] : neverType, types[i]); @@ -63084,7 +64757,7 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 2097152 /* NonInferrableType */); + var skipParameters = !!(ts.getObjectFlags(source) & 524288 /* NonInferrableType */); for (var i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -63094,7 +64767,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 === 165 /* MethodDeclaration */ || kind === 164 /* MethodSignature */ || kind === 166 /* Constructor */; + bivariant = bivariant || kind === 166 /* MethodDeclaration */ || kind === 165 /* MethodSignature */ || kind === 167 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -63135,7 +64808,7 @@ var ts; return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 65536 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 32768 /* ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { @@ -63148,7 +64821,7 @@ var ts; return candidates; } function getContravariantInference(inference) { - return inference.priority & 208 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -63165,7 +64838,7 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 208 /* PriorityImpliesCombination */ ? + var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? getUnionType(baseCandidates, 2 /* Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); @@ -63274,7 +64947,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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 290 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -63295,26 +64968,24 @@ 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 === 176 /* TypeQuery */ ? true : n.kind === 78 /* Identifier */ || n.kind === 157 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 177 /* TypeQuery */ ? true : n.kind === 78 /* Identifier */ || n.kind === 158 /* 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 // leftmost identifier followed by zero or more property names separated by dots. - // The result is undefined if the reference isn't a dotted name. We prefix nodes - // occurring in an apparent type position with '@' because the control flow type - // of such nodes may be based on the apparent type instead of the declared type. + // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { case 78 /* Identifier */: var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; case 107 /* ThisKeyword */: return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 226 /* NonNullExpression */: + case 208 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -63325,36 +64996,40 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 208 /* ParenthesizedExpression */: + case 226 /* NonNullExpression */: return isMatchingReference(source, target.expression); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { + case 227 /* MetaProperty */: + return target.kind === 227 /* MetaProperty */ + && source.keywordToken === target.keywordToken + && source.name.escapedText === target.name.escapedText; case 78 /* Identifier */: case 79 /* PrivateIdentifier */: return target.kind === 78 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 249 /* VariableDeclaration */ || target.kind === 198 /* BindingElement */) && + (target.kind === 250 /* VariableDeclaration */ || target.kind === 199 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 107 /* ThisKeyword */: return target.kind === 107 /* ThisKeyword */; case 105 /* SuperKeyword */: return target.kind === 105 /* SuperKeyword */; - case 225 /* NonNullExpression */: - case 207 /* ParenthesizedExpression */: + case 226 /* NonNullExpression */: + case 208 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); } return false; @@ -63362,11 +65037,11 @@ var ts; // Given a source x, check if target matches x or is an && operation with an operand that matches x. function containsTruthyCheck(source, target) { return isMatchingReference(source, target) || - (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && + (target.kind === 217 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); } function getAccessedPropertyName(access) { - return access.kind === 201 /* PropertyAccessExpression */ ? access.name.escapedText : + return access.kind === 202 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } @@ -63416,6 +65091,86 @@ var ts; } return result; } + // Given a set of constituent types and a property name, create and return a map keyed by the literal + // types of the property by that name in each constituent type. No map is returned if some key property + // has a non-literal type or if less than 10 or less than 50% of the constituents have a unique key. + // Entries with duplicate keys have unknownType as the value. + function mapTypesByKeyProperty(types, name) { + var map = new ts.Map(); + var count = 0; + var _loop_20 = function (type) { + if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var discriminant = getTypeOfPropertyOfType(type, name); + if (discriminant) { + if (!isLiteralType(discriminant)) { + return { value: undefined }; + } + var duplicate_1 = false; + forEachType(discriminant, function (t) { + var id = getTypeId(getRegularTypeOfLiteralType(t)); + var existing = map.get(id); + if (!existing) { + map.set(id, type); + } + else if (existing !== unknownType) { + map.set(id, unknownType); + duplicate_1 = true; + } + }); + if (!duplicate_1) + count++; + } + } + }; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; + var state_8 = _loop_20(type); + if (typeof state_8 === "object") + return state_8.value; + } + return count >= 10 && count * 2 >= types.length ? map : undefined; + } + // Return the name of a discriminant property for which it was possible and feasible to construct a map of + // 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 */) { + return undefined; + } + if (unionType.keyPropertyName === undefined) { + // The candidate key property name is the name of the first property with a unit type in one of the + // constituent types. + var keyPropertyName = ts.forEach(types, function (t) { + return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : + undefined; + }); + var mapByKeyProperty = keyPropertyName && mapTypesByKeyProperty(types, keyPropertyName); + unionType.keyPropertyName = mapByKeyProperty ? keyPropertyName : ""; + unionType.constituentMap = mapByKeyProperty; + } + return unionType.keyPropertyName.length ? unionType.keyPropertyName : undefined; + } + // Given a union type for which getKeyPropertyName returned a non-undefined result, return the constituent + // that corresponds to the given key type for that property name. + function getConstituentTypeForKeyType(unionType, keyType) { + var _a; + var result = (_a = unionType.constituentMap) === null || _a === void 0 ? void 0 : _a.get(getTypeId(getRegularTypeOfLiteralType(keyType))); + return result !== unknownType ? result : undefined; + } + function getMatchingUnionConstituentForType(unionType, type) { + var keyPropertyName = getKeyPropertyName(unionType); + var propType = keyPropertyName && getTypeOfPropertyOfType(type, keyPropertyName); + return propType && getConstituentTypeForKeyType(unionType, propType); + } + function getMatchingUnionConstituentForObjectLiteral(unionType, node) { + var keyPropertyName = getKeyPropertyName(unionType); + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 289 /* PropertyAssignment */ && + p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); + var propType = propNode && getTypeOfExpression(propNode.initializer); + return propType && getConstituentTypeForKeyType(unionType, propType); + } function isOrContainsMatchingReference(source, target) { return isMatchingReference(source, target) || containsMatchingReference(source, target); } @@ -63428,7 +65183,7 @@ var ts; } } } - if (expression.expression.kind === 201 /* PropertyAccessExpression */ && + if (expression.expression.kind === 202 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -63475,14 +65230,6 @@ var ts; } return declaredType; } - function getTypeFactsOfTypes(types) { - var result = 0 /* None */; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; - result |= getTypeFacts(t); - } - return result; - } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype // check. This gives us a quicker out in the common case where an object type is not a function. @@ -63490,7 +65237,8 @@ var ts; return !!(resolved.callSignatures.length || resolved.constructSignatures.length || resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } - function getTypeFacts(type) { + function getTypeFacts(type, ignoreObjects) { + if (ignoreObjects === void 0) { ignoreObjects = false; } var flags = type.flags; if (flags & 4 /* String */) { return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; @@ -63527,7 +65275,7 @@ var ts; (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* Object */ && !ignoreObjects) { return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ : isFunctionObjectType(type) ? @@ -63550,11 +65298,17 @@ var ts; return 0 /* None */; } if (flags & 465829888 /* Instantiable */) { - return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType) : + return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType, ignoreObjects) : strictNullChecks ? 7929345 /* NonEmptyStringStrictFacts */ : 16776705 /* NonEmptyStringFacts */; } - if (flags & 3145728 /* UnionOrIntersection */) { - return getTypeFactsOfTypes(type.types); + if (flags & 1048576 /* Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t, ignoreObjects); }, 0 /* None */); + } + if (flags & 2097152 /* Intersection */) { + // When an intersection contains a primitive type we ignore object type constituents as they are + // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. + ignoreObjects || (ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */)); + return ts.reduceLeft(type.types, function (facts, t) { return facts & getTypeFacts(t, ignoreObjects); }, 16777215 /* All */); } return 16777215 /* All */; } @@ -63562,18 +65316,16 @@ var ts; return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); } function getTypeWithDefault(type, defaultExpression) { - if (defaultExpression) { - var defaultType = getTypeOfExpression(defaultExpression); - return getUnionType([getTypeWithFacts(type, 524288 /* NEUndefined */), defaultType]); - } - return type; + return defaultExpression ? + getUnionType([getNonUndefinedType(type), getTypeOfExpression(defaultExpression)]) : + type; } function getTypeOfDestructuredProperty(type, name) { var nameType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(nameType)) return errorType; var text = getPropertyNameFromType(nameType); - return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || + return getTypeOfPropertyOfType(type, text) || isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1 /* Number */)) || includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0 /* String */)) || errorType; @@ -63594,15 +65346,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 199 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 200 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 289 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 216 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 239 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 217 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 240 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -63619,21 +65371,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: return stringType; - case 239 /* ForOfStatement */: + case 240 /* ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 210 /* DeleteExpression */: + case 211 /* DeleteExpression */: return undefinedType; - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 220 /* SpreadElement */: + case 221 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -63641,7 +65393,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 196 /* ObjectBindingPattern */ ? + var type = pattern.kind === 197 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -63659,30 +65411,30 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 238 /* ForInStatement */) { + if (node.parent.parent.kind === 239 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.parent.kind === 240 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 249 /* VariableDeclaration */ ? + return node.kind === 250 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 249 /* VariableDeclaration */ && node.initializer && + return node.kind === 250 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 198 /* BindingElement */ && node.parent.kind === 216 /* BinaryExpression */ && + node.kind !== 199 /* BindingElement */ && node.parent.kind === 217 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: switch (node.operatorToken.kind) { case 62 /* EqualsToken */: case 74 /* BarBarEqualsToken */: @@ -63697,13 +65449,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 207 /* ParenthesizedExpression */ || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || - parent.kind === 216 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 208 /* ParenthesizedExpression */ || + parent.kind === 217 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 217 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 285 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -63723,7 +65475,7 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 285 /* CaseClause */) { if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; @@ -63759,9 +65511,15 @@ var ts; function forEachType(type, f) { return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); } + function someType(type, f) { + return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + } function everyType(type, f) { return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); } + function everyContainedType(type, f) { + return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + } function filterType(type, f) { if (type.flags & 1048576 /* Union */) { var types = type.types; @@ -63909,12 +65667,12 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 203 /* CallExpression */ + parent.parent.kind === 204 /* CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 202 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 203 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 216 /* BinaryExpression */ && + parent.parent.kind === 217 /* BinaryExpression */ && parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && @@ -63922,8 +65680,8 @@ var ts; return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(declaration) { - return (declaration.kind === 249 /* VariableDeclaration */ || declaration.kind === 160 /* Parameter */ || - declaration.kind === 163 /* PropertyDeclaration */ || declaration.kind === 162 /* PropertySignature */) && + return (declaration.kind === 250 /* VariableDeclaration */ || declaration.kind === 161 /* Parameter */ || + declaration.kind === 164 /* PropertyDeclaration */ || declaration.kind === 163 /* PropertySignature */) && !!ts.getEffectiveTypeAnnotationNode(declaration); } function getExplicitTypeOfSymbol(symbol, diagnostic) { @@ -63942,7 +65700,7 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 240 /* ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { @@ -63970,7 +65728,7 @@ var ts; return getExplicitThisType(node); case 105 /* SuperKeyword */: return checkSuperExpression(node); - case 201 /* PropertyAccessExpression */: { + case 202 /* PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -63988,7 +65746,7 @@ var ts; } return undefined; } - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -64002,7 +65760,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 === 233 /* ExpressionStatement */) { + if (node.parent.kind === 234 /* ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } else if (node.expression.kind !== 105 /* SuperKeyword */) { @@ -64046,7 +65804,7 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr); - return node.kind === 94 /* FalseKeyword */ || node.kind === 216 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + return node.kind === 94 /* FalseKeyword */ || node.kind === 217 /* 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) { @@ -64181,7 +65939,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 225 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 226 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -64265,8 +66023,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 !== 201 /* PropertyAccessExpression */ && - reference.kind !== 202 /* ElementAccessExpression */ && + reference.kind !== 202 /* PropertyAccessExpression */ && + reference.kind !== 203 /* ElementAccessExpression */ && reference.kind !== 107 /* ThisKeyword */) { flow = container.flowNode; continue; @@ -64291,7 +66049,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getConstraintForLocation(node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 250 /* VariableDeclaration */ || node.kind === 199 /* BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -64331,14 +66089,14 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 208 /* FunctionExpression */ || init.kind === 209 /* ArrowFunction */)) { + if (init && (init.kind === 209 /* FunctionExpression */ || init.kind === 210 /* 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 === 238 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 239 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference @@ -64349,7 +66107,7 @@ var ts; if (node.kind === 94 /* FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 217 /* BinaryExpression */) { if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } @@ -64380,7 +66138,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 203 /* CallExpression */ ? + var expr = node.kind === 204 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -64388,7 +66146,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 204 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -64436,7 +66194,7 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 211 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 212 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { @@ -64444,12 +66202,12 @@ 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 === 211 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + else if (expr.kind === 212 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); } } if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + type = narrowTypeBySwitchOnDiscriminantProperty(type, expr, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } } return createFlowType(type, isIncomplete(flowType)); @@ -64620,8 +66378,7 @@ var ts; if (propName === undefined) { return type; } - var includesNullable = strictNullChecks && maybeTypeOfKind(type, 98304 /* Nullable */); - var removeNullable = includesNullable && ts.isOptionalChain(access); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); if (!propType) { return type; @@ -64633,6 +66390,30 @@ var ts; return !(discriminantType.flags & 131072 /* Never */) && isTypeComparableTo(discriminantType, narrowedPropType); }); } + function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { + if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + var keyPropertyName = getKeyPropertyName(type); + if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { + var candidate_2 = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); + if (candidate_2) { + return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate_2 : + isUnitType(getTypeOfPropertyOfType(candidate_2, keyPropertyName) || unknownType) ? filterType(type, function (t) { return t !== candidate_2; }) : + type; + } + } + } + return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); + } + function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); + var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); + if (candidate !== unknownType) { + return candidate; + } + } + return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeBySwitchOnDiscriminant(t, switchStatement, clauseStart, clauseEnd); }); + } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); @@ -64656,7 +66437,8 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if (type.flags & (1048576 /* Union */ | 524288 /* Object */) + if (type.flags & 1048576 /* Union */ + || type.flags & 524288 /* Object */ && declaredType !== type || isThisTypeParameter(type) || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); @@ -64675,40 +66457,40 @@ var ts; case 35 /* ExclamationEqualsToken */: case 36 /* EqualsEqualsEqualsToken */: case 37 /* ExclamationEqualsEqualsToken */: - var operator_1 = expr.operatorToken.kind; - var left_1 = getReferenceCandidate(expr.left); - var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { - return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); + var operator = expr.operatorToken.kind; + var left = getReferenceCandidate(expr.left); + var right = getReferenceCandidate(expr.right); + if (left.kind === 212 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right_1.kind === 211 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { - return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); + if (right.kind === 212 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } - if (isMatchingReference(reference, left_1)) { - return narrowTypeByEquality(type, operator_1, right_1, assumeTrue); + if (isMatchingReference(reference, left)) { + return narrowTypeByEquality(type, operator, right, assumeTrue); } - if (isMatchingReference(reference, right_1)) { - return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); + if (isMatchingReference(reference, right)) { + return narrowTypeByEquality(type, operator, left, assumeTrue); } if (strictNullChecks) { - if (optionalChainContainsReference(left_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + if (optionalChainContainsReference(left, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, right, assumeTrue); } - else if (optionalChainContainsReference(right_1, reference)) { - type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + else if (optionalChainContainsReference(right, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator, left, assumeTrue); } } - if (isMatchingReferenceDiscriminant(left_1, type)) { - return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(left, type)) { + return narrowTypeByDiscriminantProperty(type, left, operator, right, assumeTrue); } - if (isMatchingReferenceDiscriminant(right_1, type)) { - return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); + if (isMatchingReferenceDiscriminant(right, type)) { + return narrowTypeByDiscriminantProperty(type, right, operator, left, assumeTrue); } - if (isMatchingConstructorReference(left_1)) { - return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue); + if (isMatchingConstructorReference(left)) { + return narrowTypeByConstructor(type, operator, right, assumeTrue); } - if (isMatchingConstructorReference(right_1)) { - return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue); + if (isMatchingConstructorReference(right)) { + return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; case 101 /* InstanceOfKeyword */: @@ -64773,13 +66555,12 @@ var ts; } if (assumeTrue) { var filterFn = operator === 34 /* EqualsEqualsToken */ ? - (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : + function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); } if (isUnitType(valueType)) { - var regularType_1 = getRegularTypeOfLiteralType(valueType); - return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; }); + return filterType(type, function (t) { return !(isUnitLikeType(t) && areTypesComparable(t, valueType)); }); } return type; } @@ -64801,7 +66582,7 @@ var ts; if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { // The pattern x && typeof x === 'object', where x is of type unknown, narrows x to type object. We don't // need to check for the reverse typeof x === 'object' && x since that already narrows correctly. - if (typeOfExpr.parent.parent.kind === 216 /* BinaryExpression */) { + if (typeOfExpr.parent.parent.kind === 217 /* BinaryExpression */) { var expr = typeOfExpr.parent.parent; if (expr.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { return nonPrimitiveType; @@ -64857,7 +66638,7 @@ var ts; if (!hasDefaultClause) { return caseType; } - var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); + var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); } function getImpliedTypeFromTypeofGuard(type, text) { @@ -65039,7 +66820,16 @@ var ts; } function getNarrowedType(type, candidate, assumeTrue, isRelated) { if (!assumeTrue) { - return filterType(type, function (t) { return !isRelated(t, candidate); }); + 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; + }); } // 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. @@ -65100,17 +66890,17 @@ var ts; case 78 /* Identifier */: case 107 /* ThisKeyword */: case 105 /* SuperKeyword */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 203 /* CallExpression */: + case 204 /* CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 207 /* ParenthesizedExpression */: - case 225 /* NonNullExpression */: + case 208 /* ParenthesizedExpression */: + case 226 /* NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -65134,17 +66924,20 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 78 /* Identifier */) { + if (location.kind === 78 /* Identifier */ || location.kind === 79 /* PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } - if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) { + if (ts.isExpressionNode(location) && (!ts.isAssignmentTarget(location) || ts.isWriteAccess(location))) { var type = getTypeOfExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; } } } + if (ts.isDeclarationName(location) && ts.isSetAccessor(location.parent) && getAnnotatedAccessorTypeNode(location.parent)) { + return resolveTypeOfAccessors(location.parent.symbol, /*writing*/ true); + } // The location isn't a reference to the given symbol, meaning we're being asked // a hypothetical question of what type the symbol would have if there was a reference // to it at the given location. Since we have no control flow information for the @@ -65155,13 +66948,16 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 257 /* ModuleBlock */ || - node.kind === 297 /* SourceFile */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 258 /* ModuleBlock */ || + node.kind === 298 /* SourceFile */ || + node.kind === 164 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. function isParameterAssigned(symbol) { + if (!symbol.valueDeclaration) { + return false; + } var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(func); if (!(links.flags & 8388608 /* AssignmentsMarked */)) { @@ -65179,7 +66975,7 @@ var ts; if (node.kind === 78 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 161 /* Parameter */) { symbol.isAssigned = true; } } @@ -65195,7 +66991,7 @@ var ts; function removeOptionalityFromDeclaredType(declaredType, declaration) { if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 160 /* Parameter */ && + declaration.kind === 161 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -65209,23 +67005,40 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 201 /* PropertyAccessExpression */ || - parent.kind === 203 /* CallExpression */ && parent.expression === node || - parent.kind === 202 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 198 /* BindingElement */ && parent.name === node && !!parent.initializer; - } - function typeHasNullableConstraint(type) { - return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); - } - function getConstraintForLocation(type, node) { - // When a node is the left hand expression of a property access, element access, or call expression, - // and the type of the node includes type variables with constraints that are nullable, we fetch the - // apparent type of the node *before* performing control flow analysis such that narrowings apply to - // the constraint type. - if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) { - return mapType(getWidenedType(type), getBaseConstraintOrType); - } - return type; + // In an element access obj[x], we consider obj to be in a constraint position only when x is not + // of a generic type. This is because when both obj and x are of generic types T and K, we want + // the resulting type to be T[K]. + return parent.kind === 202 /* PropertyAccessExpression */ || + parent.kind === 204 /* CallExpression */ && parent.expression === node || + parent.kind === 203 /* ElementAccessExpression */ && parent.expression === node && + !isGenericIndexType(getTypeOfExpression(parent.argumentExpression)); + } + function isGenericTypeWithUnionConstraint(type) { + return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + } + function containsGenericType(type) { + return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType)); + } + function hasContextualTypeWithNoGenericTypes(node) { + // Computing the contextual type for a child of a JSX element involves resolving the type of the + // element's tag name, so we exclude that here to avoid circularities. + var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && + !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && + getContextualType(node); + return contextualType && !someType(contextualType, containsGenericType); + } + function getNarrowableTypeForReference(type, reference, checkMode) { + // When the type of a reference is or contains an instantiable type with a union type constraint, and + // when the reference is in a constraint position (where it is known we'll obtain the apparent type) or + // has a contextual type containing no top-level instantiables (meaning constraints will determine + // assignability), we substitute constraints for all instantiables in the type of the reference to give + // control flow analysis an opportunity to narrow it further. For example, for a reference of a type + // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute + // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. + var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + someType(type, isGenericTypeWithUnionConstraint) && + (isConstraintPosition(reference) || hasContextualTypeWithNoGenericTypes(reference)); + 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); }); @@ -65248,7 +67061,7 @@ var ts; } } } - function checkIdentifier(node) { + function checkIdentifier(node, checkMode) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { return errorType; @@ -65262,7 +67075,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 209 /* ArrowFunction */) { + if (container.kind === 210 /* 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 */)) { @@ -65279,15 +67092,15 @@ var ts; } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var sourceSymbol = localOrExportSymbol.flags & 2097152 /* Alias */ ? resolveAlias(localOrExportSymbol) : localOrExportSymbol; - if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { + if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) { addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* Class */) { // 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 === 252 /* ClassDeclaration */ + if (declaration.kind === 253 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -65299,14 +67112,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 221 /* ClassExpression */) { + else if (declaration.kind === 222 /* 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 !== 297 /* SourceFile */) { + while (container.kind !== 298 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 163 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { + if (container.kind === 164 /* PropertyDeclaration */ && ts.hasSyntacticModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -65317,12 +67130,18 @@ var ts; } } checkNestedBlockScopedBinding(node, symbol); - var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node); + var type = getTypeOfSymbol(localOrExportSymbol); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); + var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; + error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { @@ -65344,7 +67163,7 @@ var ts; } } else if (isAlias) { - declaration = ts.find(symbol.declarations, isSomeImportDeclaration); + declaration = getDeclarationOfAliasSymbol(symbol); } else { return type; @@ -65352,10 +67171,11 @@ var ts; if (!declaration) { return type; } + type = getNarrowableTypeForReference(type, node, checkMode); // 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 === 160 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 161 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -65364,8 +67184,8 @@ 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 === 208 /* FunctionExpression */ || - flowContainer.kind === 209 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 209 /* FunctionExpression */ || + flowContainer.kind === 210 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -65374,9 +67194,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 === 270 /* ExportSpecifier */) || - node.parent.kind === 225 /* NonNullExpression */ || - declaration.kind === 249 /* VariableDeclaration */ && declaration.exclamationToken || + isInTypeQuery(node) || node.parent.kind === 271 /* ExportSpecifier */) || + node.parent.kind === 226 /* NonNullExpression */ || + declaration.kind === 250 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -65401,17 +67221,21 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } - function isInsideFunction(node, threshold) { - return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); + function isInsideFunctionOrInstancePropertyInitializer(node, threshold) { + return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); }); } function getPartOfForStatementContainingNode(node, container) { return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; }); } + function getEnclosingIterationStatement(node) { + return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); + } function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 287 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 288 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -65419,22 +67243,14 @@ var ts; // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); - var usedInFunction = isInsideFunction(node.parent, container); - var current = container; - var containedInIterationStatement = false; - while (current && !ts.nodeStartsNewLexicalEnvironment(current)) { - if (ts.isIterationStatement(current, /*lookInLabeledStatements*/ false)) { - containedInIterationStatement = true; - break; - } - current = current.parent; - } - if (containedInIterationStatement) { - if (usedInFunction) { + var isCaptured = isInsideFunctionOrInstancePropertyInitializer(node, container); + var enclosingIterationStatement = getEnclosingIterationStatement(container); + if (enclosingIterationStatement) { + if (isCaptured) { // 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 251 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { @@ -65449,13 +67265,13 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(current).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; } } // 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, 250 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 251 /* VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -65463,7 +67279,7 @@ var ts; // set 'declared inside loop' bit on the block-scoped binding getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; } - if (usedInFunction) { + if (isCaptured) { getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; } } @@ -65474,7 +67290,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 207 /* ParenthesizedExpression */) { + while (current.parent.kind === 208 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -65482,7 +67298,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 214 /* PrefixUnaryExpression */ || current.parent.kind === 215 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 215 /* PrefixUnaryExpression */ || current.parent.kind === 216 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } @@ -65495,7 +67311,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 163 /* PropertyDeclaration */ || container.kind === 166 /* Constructor */) { + if (container.kind === 164 /* PropertyDeclaration */ || container.kind === 167 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -65535,37 +67351,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 166 /* Constructor */) { + if (container.kind === 167 /* 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 === 209 /* ArrowFunction */) { + if (container.kind === 210 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 256 /* ModuleDeclaration */: + case 257 /* 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 255 /* EnumDeclaration */: + case 256 /* 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 166 /* Constructor */: + case 167 /* 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 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + if (ts.hasSyntacticModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && useDefineForClassFields)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -65653,7 +67469,7 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 208 /* FunctionExpression */ && + if (container.kind === 209 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -65663,16 +67479,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 165 /* MethodDeclaration */ && - container.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 166 /* MethodDeclaration */ && + container.parent.kind === 201 /* 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 === 208 /* FunctionExpression */ && - container.parent.kind === 288 /* PropertyAssignment */ && - container.parent.parent.kind === 200 /* ObjectLiteralExpression */ && + else if (container.kind === 209 /* FunctionExpression */ && + container.parent.kind === 289 /* PropertyAssignment */ && + container.parent.parent.kind === 201 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -65680,7 +67496,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 === 208 /* FunctionExpression */ && + else if (container.kind === 209 /* 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") && @@ -65705,7 +67521,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 308 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 309 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -65719,16 +67535,16 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 161 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 203 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 204 /* 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 === 209 /* ArrowFunction */) { + while (container && container.kind === 210 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -65741,14 +67557,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158 /* ComputedPropertyName */; }); - if (current && current.kind === 158 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 159 /* ComputedPropertyName */; }); + if (current && current.kind === 159 /* 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 === 200 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 201 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -65756,7 +67572,7 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 166 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 167 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasSyntacticModifier(container, 32 /* Static */) || isCallExpression) { @@ -65825,7 +67641,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 === 165 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 166 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -65839,7 +67655,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 200 /* ObjectLiteralExpression */) { + if (container.parent.kind === 201 /* 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; @@ -65860,7 +67676,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 166 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 167 /* 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; @@ -65875,7 +67691,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 === 166 /* Constructor */; + return container.kind === 167 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -65883,21 +67699,21 @@ 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 === 200 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 201 /* ObjectLiteralExpression */) { if (ts.hasSyntacticModifier(container, 32 /* Static */)) { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */; + return container.kind === 166 /* MethodDeclaration */ || + container.kind === 165 /* MethodSignature */ || + container.kind === 168 /* GetAccessor */ || + container.kind === 169 /* SetAccessor */; } else { - return container.kind === 165 /* MethodDeclaration */ || - container.kind === 164 /* MethodSignature */ || - container.kind === 167 /* GetAccessor */ || - container.kind === 168 /* SetAccessor */ || - container.kind === 163 /* PropertyDeclaration */ || - container.kind === 162 /* PropertySignature */ || - container.kind === 166 /* Constructor */; + return container.kind === 166 /* MethodDeclaration */ || + container.kind === 165 /* MethodSignature */ || + container.kind === 168 /* GetAccessor */ || + container.kind === 169 /* SetAccessor */ || + container.kind === 164 /* PropertyDeclaration */ || + container.kind === 163 /* PropertySignature */ || + container.kind === 167 /* Constructor */; } } } @@ -65905,10 +67721,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 165 /* MethodDeclaration */ || - func.kind === 167 /* GetAccessor */ || - func.kind === 168 /* SetAccessor */) && func.parent.kind === 200 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 208 /* FunctionExpression */ && func.parent.kind === 288 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 166 /* MethodDeclaration */ || + func.kind === 168 /* GetAccessor */ || + func.kind === 169 /* SetAccessor */) && func.parent.kind === 201 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 209 /* FunctionExpression */ && func.parent.kind === 289 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -65920,7 +67736,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 210 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -65947,7 +67763,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 288 /* PropertyAssignment */) { + if (literal.parent.kind !== 289 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -65961,7 +67777,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 === 216 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { + if (parent.kind === 217 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -66014,11 +67830,11 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 160 /* Parameter */: + case 161 /* Parameter */: return getContextuallyTypedParameterType(declaration); - case 198 /* BindingElement */: + case 199 /* BindingElement */: return getContextualTypeForBindingElement(declaration); - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: if (ts.hasSyntacticModifier(declaration, 32 /* Static */)) { return getContextualTypeForStaticPropertyDeclaration(declaration); } @@ -66029,10 +67845,10 @@ var ts; var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 198 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); + parent.kind !== 199 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 197 /* ArrayBindingPattern */) { + if (parent.name.kind === 198 /* ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -66169,7 +67985,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 205 /* TaggedTemplateExpression */) { + if (template.parent.kind === 206 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -66203,16 +68019,16 @@ var ts; // In an assignment expression, the right operand is contextually typed by the type of the left operand. // Don't do this for assignment declarations unless there is a type tag on the assignment, to avoid circularity from checking the right operand. function getContextualTypeForAssignmentDeclaration(binaryExpression) { + var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { case 0 /* None */: return getTypeOfExpression(binaryExpression.left); + case 4 /* ThisProperty */: + return getContextualTypeForThisPropertyAssignment(binaryExpression); case 5 /* Property */: - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + return getContextualTypeForThisPropertyAssignment(binaryExpression); } // If `binaryExpression.left` was assigned a symbol, then this is a new declaration; otherwise it is an assignment to an existing declaration. // See `bindStaticPropertyAssignment` in `binder.ts`. @@ -66233,11 +68049,11 @@ var ts; var id = lhs.expression; var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { - var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); - if (annotated) { + var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); + if (annotated_1) { var nameStr = ts.getElementOrPropertyAccessName(lhs); if (nameStr !== undefined) { - return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr); + return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated_1), nameStr); } } return undefined; @@ -66245,9 +68061,15 @@ var ts; } return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left); } + case 1 /* ExportsProperty */: + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: + var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; + // falls through case 2 /* ModuleExports */: - case 4 /* ThisProperty */: - return getContextualTypeForThisPropertyAssignment(binaryExpression, kind); + valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); + var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); + return annotated ? getTypeFromTypeNode(annotated) : undefined; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -66268,7 +68090,7 @@ var ts; var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } - function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) { + function getContextualTypeForThisPropertyAssignment(binaryExpression) { if (!binaryExpression.symbol) return getTypeOfExpression(binaryExpression.left); if (binaryExpression.symbol.valueDeclaration) { @@ -66280,8 +68102,6 @@ var ts; } } } - if (kind === 2 /* ModuleExports */) - return undefined; var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return undefined; @@ -66336,6 +68156,10 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + if (propertyAssignmentType) { + return propertyAssignmentType; + } var type = getApparentTypeOfContextualType(objectLiteral, contextFlags); if (type) { if (hasBindableName(element)) { @@ -66424,19 +68248,19 @@ var ts; case 78 /* Identifier */: case 150 /* UndefinedKeyword */: return true; - case 201 /* PropertyAccessExpression */: - case 207 /* ParenthesizedExpression */: + case 202 /* PropertyAccessExpression */: + case 208 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 288 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 289 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 280 /* 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]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 281 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return 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. @@ -66447,15 +68271,9 @@ var ts; var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - if (apparentType.flags & 1048576 /* Union */) { - if (ts.isObjectLiteralExpression(node)) { - return discriminateContextualTypeByObjectMembers(node, apparentType); - } - else if (ts.isJsxAttributes(node)) { - return discriminateContextualTypeByJSXAttributes(node, apparentType); - } - } - return apparentType; + return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing @@ -66522,60 +68340,60 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 198 /* BindingElement */: + case 250 /* VariableDeclaration */: + case 161 /* Parameter */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 199 /* BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 209 /* ArrowFunction */: - case 242 /* ReturnStatement */: + case 210 /* ArrowFunction */: + case 243 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 219 /* YieldExpression */: + case 220 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 213 /* AwaitExpression */: + case 214 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 203 /* CallExpression */: + case 204 /* CallExpression */: if (parent.expression.kind === 99 /* ImportKeyword */) { return stringType; } /* falls through */ - case 204 /* NewExpression */: + case 205 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 207 /* TypeAssertionExpression */: + case 225 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 289 /* PropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 290 /* SpreadAssignment */: - return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 199 /* ArrayLiteralExpression */: { + case 291 /* SpreadAssignment */: + return getContextualType(parent.parent, contextFlags); + case 200 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 228 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 218 /* TemplateExpression */); + case 229 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 219 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 207 /* ParenthesizedExpression */: { + case 208 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 225 /* NonNullExpression */: + case 226 /* NonNullExpression */: return getContextualType(parent, contextFlags); - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: + case 281 /* JsxAttribute */: + case 283 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxOpeningElement */: + case 275 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; @@ -66611,14 +68429,14 @@ var ts; return propsType; } function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) { - if (sig.unionSignatures) { + if (sig.compositeSignatures) { // JSX Elements using the legacy `props`-field based lookup (eg, react class components) need to treat the `props` member as an input // instead of an output position when resolving the signature. We need to go back to the input signatures of the composite signature, // get the type of `props` on each return type individually, and then _intersect them_, rather than union them (as would normally occur // for a union signature). It's an unfortunate quirk of looking in the output of the signature for the type we want to use for the input. // The default behavior of `getTypeOfFirstParameterOfSignatureWithFallback` when no `props` member name is defined is much more sane. var results = []; - for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) { + for (var _i = 0, _a = sig.compositeSignatures; _i < _a.length; _i++) { var signature = _a[_i]; var instance = getReturnTypeOfSignature(signature); if (isTypeAny(instance)) { @@ -66630,7 +68448,7 @@ var ts; } results.push(propType); } - return getIntersectionType(results); + return getIntersectionType(results); // Same result for both union and intersection signatures } var instanceType = getReturnTypeOfSignature(sig); return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation); @@ -66712,16 +68530,93 @@ var ts; return apparentAttributesType; } } + function getIntersectedSignatures(signatures) { + return ts.getStrictOptionValue(compilerOptions, "noImplicitAny") + ? ts.reduceLeft(signatures, function (left, right) { + return left === right || !left ? left + : compareTypeParametersIdentical(left.typeParameters, right.typeParameters) ? combineSignaturesOfIntersectionMembers(left, right) + : undefined; + }) + : undefined; + } + function combineIntersectionThisParam(left, right, mapper) { + if (!left || !right) { + return left || right; + } + // A signature `this` type might be a read or a write position... It's very possible that it should be invariant + // and we should refuse to merge signatures if there are `this` types and they do not match. However, so as to be + // pessimistic when contextual typing, for now, we'll union the `this` types. + var thisType = getUnionType([getTypeOfSymbol(left), instantiateType(getTypeOfSymbol(right), mapper)]); + return createSymbolWithType(left, thisType); + } + function combineIntersectionParameters(left, right, mapper) { + var leftCount = getParameterCount(left); + var rightCount = getParameterCount(right); + var longest = leftCount >= rightCount ? left : right; + var shorter = longest === left ? right : left; + var longestCount = longest === left ? leftCount : rightCount; + var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right)); + var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest); + var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0)); + for (var i = 0; i < longestCount; i++) { + var longestParamType = tryGetTypeAtPosition(longest, i); + if (longest === right) { + longestParamType = instantiateType(longestParamType, mapper); + } + var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType; + if (shorter === right) { + shorterParamType = instantiateType(shorterParamType, mapper); + } + var unionParamType = getUnionType([longestParamType, shorterParamType]); + var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1); + var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter); + var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i); + var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i); + var paramName = leftName === rightName ? leftName : + !leftName ? rightName : + !rightName ? leftName : + undefined; + var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; + params[i] = paramSymbol; + } + if (needsExtraRestElement) { + var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); + if (shorter === right) { + restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); + } + params[longestCount] = restParamSymbol; + } + return params; + } + function combineSignaturesOfIntersectionMembers(left, right) { + var typeParams = left.typeParameters || right.typeParameters; + var paramMapper; + if (left.typeParameters && right.typeParameters) { + paramMapper = createTypeMapper(right.typeParameters, left.typeParameters); + // We just use the type parameter defaults from the first signature + } + var declaration = left.declaration; + var params = combineIntersectionParameters(left, right, paramMapper); + var thisParam = combineIntersectionThisParam(left.thisParameter, right.thisParameter, paramMapper); + var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); + var result = createSignature(declaration, typeParams, thisParam, params, + /*resolvedReturnType*/ undefined, + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); + result.compositeKind = 2097152 /* Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + if (paramMapper) { + result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + } + return result; + } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { var signatures = getSignaturesOfType(type, 0 /* Call */); - if (signatures.length === 1) { - var signature = signatures[0]; - if (!isAritySmaller(signature, node)) { - return signature; - } - } + var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); + return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } /** If the contextual signature has fewer parameters than the function expression, do not use it */ function isAritySmaller(signature, target) { @@ -66738,7 +68633,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 208 /* FunctionExpression */ || node.kind === 209 /* ArrowFunction */; + return node.kind === 209 /* FunctionExpression */ || node.kind === 210 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -66752,7 +68647,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 !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 166 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -66800,8 +68695,8 @@ var ts; return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 198 /* BindingElement */ && !!node.initializer) || - (node.kind === 216 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); + return (node.kind === 199 /* BindingElement */ && !!node.initializer) || + (node.kind === 217 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -66813,7 +68708,7 @@ var ts; var inConstContext = isConstContext(node); for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 220 /* SpreadElement */) { + if (e.kind === 221 /* SpreadElement */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); } @@ -66856,7 +68751,7 @@ var ts; if (inDestructuringPattern) { return createTupleType(elementTypes, elementFlags); } - if (forceTuple || inConstContext || contextualType && forEachType(contextualType, isTupleLikeType)) { + if (forceTuple || inConstContext || contextualType && someType(contextualType, isTupleLikeType)) { return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? @@ -66870,13 +68765,13 @@ var ts; var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 65536 /* ArrayLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 32768 /* ArrayLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: return isNumericComputedName(name); case 78 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -66923,6 +68818,20 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { 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.) + if (ts.isPropertyDeclaration(node.parent) && !ts.hasStaticModifier(node.parent) && ts.isClassExpression(node.parent.parent)) { + var container = ts.getEnclosingBlockScopeContainer(node.parent.parent); + var enclosingIterationStatement = getEnclosingIterationStatement(container); + if (enclosingIterationStatement) { + // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + // The generated variable which stores the computed field name must be block-scoped. + getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + // The generated variable which stores the class must be block-scoped. + getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + } + } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). if (links.resolvedType.flags & 98304 /* Nullable */ || @@ -66930,9 +68839,6 @@ var ts; !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } - else { - checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, /*reportError*/ true); - } } return links.resolvedType; } @@ -66972,7 +68878,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 196 /* ObjectBindingPattern */ || contextualType.pattern.kind === 200 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 197 /* ObjectBindingPattern */ || contextualType.pattern.kind === 201 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -66987,7 +68893,7 @@ var ts; // which may never occur. for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; - if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) { + if (elem.name && ts.isComputedPropertyName(elem.name)) { checkComputedPropertyName(elem.name); } } @@ -66995,16 +68901,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 === 158 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 159 /* ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 288 /* PropertyAssignment */ || - memberDecl.kind === 289 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 289 /* PropertyAssignment */ || + memberDecl.kind === 290 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 288 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 289 /* 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 === 289 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 290 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -67016,7 +68922,7 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 917504 /* PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : @@ -67027,8 +68933,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 === 288 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 289 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 289 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 290 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -67054,7 +68960,7 @@ var ts; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } - else if (memberDecl.kind === 290 /* SpreadAssignment */) { + else if (memberDecl.kind === 291 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -67066,15 +68972,20 @@ var ts; hasComputedNumberProperty = false; } var type = getReducedType(checkExpression(memberDecl.expression)); - if (!isValidSpreadType(type)) { - error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return errorType; + if (isValidSpreadType(type)) { + if (allPropertiesTable) { + checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + } + offset = propertiesArray.length; + if (spread === errorType) { + continue; + } + spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); } - if (allPropertiesTable) { - checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + else { + error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); + spread = errorType; } - spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); - offset = propertiesArray.length; continue; } else { @@ -67083,7 +68994,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 === 167 /* GetAccessor */ || memberDecl.kind === 168 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 168 /* GetAccessor */ || memberDecl.kind === 169 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -67108,7 +69019,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 !== 290 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 291 /* 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)) { @@ -67120,6 +69031,9 @@ var ts; } } } + if (spread === errorType) { + return errorType; + } if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -67136,9 +69050,9 @@ var ts; var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 16384 /* JSLiteral */; + result.objectFlags |= 8192 /* JSLiteral */; } if (patternWithComputedProperties) { result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; @@ -67228,14 +69142,14 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 4096 /* JsxAttributes */; + var objectFlags = 2048 /* JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 3670016 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(exprType) & 917504 /* PropagatingFlags */; var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -67251,7 +69165,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 282 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 283 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -67277,7 +69191,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 273 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 274 /* 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); @@ -67293,7 +69207,7 @@ var ts; // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : - childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : + childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); // Fake up a property declaration for the children childrenPropSymbol.valueDeclaration = ts.factory.createPropertySignature(/*modifiers*/ undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), /*questionToken*/ undefined, /*type*/ undefined); @@ -67319,7 +69233,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 1048576 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 262144 /* ContainsObjectOrArrayLiteral */; return result; } } @@ -67334,7 +69248,7 @@ var ts; childrenTypes.push(stringType); } } - else if (child.kind === 283 /* JsxExpression */ && !child.expression) { + else if (child.kind === 284 /* JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -67485,7 +69399,7 @@ var ts; else if (propertiesOfJsxElementAttribPropInterface.length === 1) { return propertiesOfJsxElementAttribPropInterface[0].escapedName; } - else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + else if (propertiesOfJsxElementAttribPropInterface.length > 1 && jsxElementAttribPropInterfaceSym.declarations) { // More than one property on ElementAttributesProperty is an error error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer)); } @@ -67595,11 +69509,11 @@ var ts; if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { - return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol); + return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = - getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0 /* String */); + getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), 0 /* String */) || errorType; } else { return links.resolvedJsxElementAttributesType = errorType; @@ -67752,9 +69666,12 @@ var ts; * @param type 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. */ - function checkPropertyAccessibility(node, isSuper, type, prop) { - var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 157 /* QualifiedName */ ? node.right : node.kind === 195 /* ImportType */ ? node : node.name; + function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { + if (reportError === void 0) { reportError = true; } + var flags = ts.getDeclarationModifierFlagsFromSymbol(prop, writing); + var errorNode = node.kind === 158 /* QualifiedName */ ? node.right : + node.kind === 196 /* ImportType */ ? node : + node.kind === 199 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; if (isSuper) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -67765,7 +69682,9 @@ 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)) { - error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + if (reportError) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + } return false; } } @@ -67774,24 +69693,22 @@ 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. - error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { + if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + (ts.isThisProperty(node) || ts.isThisInitializedObjectBindingExpression(node) || ts.isObjectBindingPattern(node.parent) && ts.isThisInitializedDeclaration(node.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) { - 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 - return false; - } - } - if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) { - if (!ts.getContainingClass(node)) { - error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + 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 + } return false; } - return true; } // Public properties are otherwise accessible. if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { @@ -67802,7 +69719,9 @@ var ts; if (flags & 8 /* Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + if (reportError) { + error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop))); + } return false; } return true; @@ -67816,7 +69735,7 @@ var ts; // of the property as base classes var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)); - return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined; + return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined; }); // A protected property is accessible if the property is within the declaring class or classes derived from it if (!enclosingClass) { @@ -67824,7 +69743,9 @@ var ts; // static member access is disallow var thisParameter = void 0; if (flags & 32 /* Static */ || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || 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)); + } return false; } var thisType = getTypeFromTypeNode(thisParameter.type); @@ -67839,7 +69760,9 @@ var ts; type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); // TODO: GH#18217 Use a different variable that's allowed to be undefined } if (!type || !hasBaseType(type, enclosingClass)) { - error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(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)); + } return false; } return true; @@ -67895,20 +69818,20 @@ var ts; } return nonNullType; } - function checkPropertyAccessExpression(node) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : - checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + function checkPropertyAccessExpression(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } - function checkPropertyAccessChain(node) { + function checkPropertyAccessChain(node, checkMode) { var leftType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(leftType, node.expression); - return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name, checkMode), node, nonOptionalType !== leftType); } - function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); + function checkQualifiedName(node, checkMode) { + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 207 /* ParenthesizedExpression */) { + while (node.parent.kind === 208 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -67943,14 +69866,13 @@ var ts; } var diagName = diagnosticName(right); if (propertyOnType) { - var typeValueDecl = propertyOnType.valueDeclaration; - var typeClass_1 = ts.getContainingClass(typeValueDecl); - ts.Debug.assert(!!typeClass_1); + var typeValueDecl = ts.Debug.checkDefined(propertyOnType.valueDeclaration); + var typeClass_1 = ts.Debug.checkDefined(ts.getContainingClass(typeValueDecl)); // We found a private identifier property with the same description. // Either: // - There is a lexically scoped private identifier AND it shadows the one we found on the type. // - It is an attempt to access the private identifier outside of the class. - if (lexicallyScopedIdentifier) { + if (lexicallyScopedIdentifier === null || lexicallyScopedIdentifier === void 0 ? void 0 : lexicallyScopedIdentifier.valueDeclaration) { var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration; var lexicalClass = ts.getContainingClass(lexicalValueDecl); ts.Debug.assert(!!lexicalClass); @@ -67969,17 +69891,42 @@ var ts; return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop)) && ts.getThisContainer(node, /*includeArrowFunctions*/ true) === getDeclaringConstructor(prop); } - function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { + function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); - if (ts.isPrivateIdentifier(right)) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); - } var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { + if (languageVersion < 99 /* ESNext */) { + if (assignmentKind !== 0 /* None */) { + checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + } + if (assignmentKind !== 1 /* Definite */) { + checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + } + } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); + 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)) { + var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration); + var parentStaticFieldInitializer = ts.findAncestor(node, function (n) { + if (n === lexicalClass_1) + return "quit"; + if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) { + return true; + } + return false; + }); + if (parentStaticFieldInitializer) { + var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent); + ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol"); + var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol)); + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol))); + } + } if (isAnyLike) { if (lexicallyScopedSymbol) { return apparentType; @@ -67994,6 +69941,12 @@ var ts; if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) { return errorType; } + else { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); + } + } } else { if (isAnyLike) { @@ -68041,33 +69994,38 @@ var ts; } } else { - if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { + if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) { addDeprecatedSuggestion(right, prop.declarations, right.escapedText); } checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 107 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 105 /* SuperKeyword */, apparentType, prop); + var writing = ts.isWriteAccess(node); + checkPropertyAccessibility(node, left.kind === 105 /* SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; } - propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node); + propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : writing ? getSetAccessorTypeOfSymbol(prop) : getTypeOfSymbol(prop); } - return getFlowTypeOfAccessExpression(node, prop, propType, right); + return getFlowTypeOfAccessExpression(node, prop, propType, right, checkMode); } - function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { + function getFlowTypeOfAccessExpression(node, prop, propType, errorNode, checkMode) { // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { + prop && + !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) + && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } if (propType === autoType) { return getFlowTypeOfProperty(node, prop); } + propType = getNarrowableTypeForReference(propType, node, checkMode); // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that @@ -68077,7 +70035,7 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 166 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { + if (flowContainer.kind === 167 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608 /* Ambient */)) { assumeUninitialized = true; } } @@ -68104,13 +70062,14 @@ var ts; var diagnosticMessage; var declarationName = ts.idText(right); if (isInPropertyInitializer(node) + && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !isPropertyDeclaredInAncestorClass(prop)) { + && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 252 /* ClassDeclaration */ && - node.parent.kind !== 173 /* TypeReference */ && + else if (valueDeclaration.kind === 253 /* ClassDeclaration */ && + node.parent.kind !== 174 /* TypeReference */ && !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); @@ -68122,22 +70081,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: return true; - case 288 /* PropertyAssignment */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 290 /* SpreadAssignment */: - case 158 /* ComputedPropertyName */: - case 228 /* TemplateSpan */: - case 283 /* JsxExpression */: - case 280 /* JsxAttribute */: - case 281 /* JsxAttributes */: - case 282 /* JsxSpreadAttribute */: - case 275 /* JsxOpeningElement */: - case 223 /* ExpressionWithTypeArguments */: - case 286 /* HeritageClause */: + case 289 /* PropertyAssignment */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 291 /* SpreadAssignment */: + case 159 /* ComputedPropertyName */: + case 229 /* TemplateSpan */: + case 284 /* JsxExpression */: + case 281 /* JsxAttribute */: + case 282 /* JsxAttributes */: + case 283 /* JsxSpreadAttribute */: + case 276 /* JsxOpeningElement */: + case 224 /* ExpressionWithTypeArguments */: + case 287 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -68209,7 +70168,10 @@ var ts; relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); } else { - errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container); + var diagnostic = containerSeemsToBeEmptyDomElement(containingType) + ? ts.Diagnostics.Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom + : ts.Diagnostics.Property_0_does_not_exist_on_type_1; + errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), diagnostic, missingProperty, container); } } } @@ -68220,9 +70182,14 @@ var ts; } diagnostics.add(resultDiagnostic); } + function containerSeemsToBeEmptyDomElement(containingType) { + return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) && + everyContainedType(containingType, function (type) { return type.symbol && /^(EventTarget|Node|((HTML[a-zA-Z]*)?Element))$/.test(ts.unescapeLeadingUnderscores(type.symbol.escapedName)); }) && + isEmptyObjectType(containingType); + } function typeHasStaticProperty(propName, containingType) { var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName); - return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); + return prop !== undefined && !!prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32 /* Static */); } function getSuggestedLibForNonExistentName(name) { var missingName = diagnosticName(name); @@ -68253,7 +70220,15 @@ var ts; } } function getSuggestedSymbolForNonexistentProperty(name, containingType) { - return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551 /* Value */); + var props = getPropertiesOfType(containingType); + if (typeof name !== "string") { + var parent_2 = name.parent; + if (ts.isPropertyAccessExpression(parent_2)) { + props = ts.filter(props, function (prop) { return isValidPropertyAccessForCompletions(parent_2, containingType, prop); }); + } + name = ts.idText(name); + } + return getSpellingSuggestionForName(name, props, 111551 /* Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -68348,20 +70323,20 @@ var ts; return undefined; } } - function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); - var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); + var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { return; } - if (isThisAccess) { + if (isSelfTypeAccess) { // Find any FunctionLikeDeclaration because those create a new 'this' binding. But this should only matter for methods (or getters/setters). var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration); if (containingMethod && containingMethod.symbol === prop) { @@ -68370,18 +70345,22 @@ var ts; } (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; } + function isSelfTypeAccess(name, parent) { + return name.kind === 107 /* ThisKeyword */ + || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); + } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression.kind === 105 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 195 /* ImportType */: + case 196 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 201 /* PropertyAccessExpression */ && node.expression.kind === 105 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 202 /* PropertyAccessExpression */ && node.expression.kind === 105 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -68390,11 +70369,11 @@ var ts; } var prop = getPropertyOfType(type, propertyName); if (prop) { - if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) { + 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, type, prop); + return checkPropertyAccessibility(node, isSuper, /*writing*/ false, type, prop, /* reportError */ false); } // 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); }); @@ -68404,7 +70383,7 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer.kind === 251 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -68433,7 +70412,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 238 /* ForInStatement */ && + if (node.kind === 239 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -68446,16 +70425,16 @@ var ts; } return false; } - function checkIndexedAccess(node) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : - checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + function checkIndexedAccess(node, checkMode) { + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } - function checkElementAccessChain(node) { + function checkElementAccessChain(node, checkMode) { var exprType = checkExpression(node.expression); var nonOptionalType = getOptionalExpressionType(exprType, node.expression); - return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } - function checkElementAccessExpression(node, exprType) { + function checkElementAccessExpression(node, exprType, checkMode) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); @@ -68471,42 +70450,7 @@ var ts; 2 /* Writing */ | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 /* NoIndexSignatures */ : 0) : 0 /* None */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, /*noUncheckedIndexedAccessCandidate*/ undefined, node, accessFlags | 16 /* ExpressionPosition */) || errorType; - return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node); - } - function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === errorType) { - // There is already an error, so no need to report one. - return false; - } - if (!ts.isWellKnownSymbolSyntactically(expression)) { - return false; - } - // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 12288 /* ESSymbolLike */) === 0) { - if (reportError) { - error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); - } - return false; - } - // The name is Symbol., so make sure Symbol actually resolves to the - // global Symbol object - var leftHandSide = expression.expression; - var leftHandSideSymbol = getResolvedSymbol(leftHandSide); - if (!leftHandSideSymbol) { - return false; - } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ true); - if (!globalESSymbol) { - // Already errored when we tried to look up the symbol - return false; - } - if (leftHandSideSymbol !== globalESSymbol) { - if (reportError) { - error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object); - } - return false; - } - return true; + return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } function callLikeExpressionMayHaveTypeArguments(node) { return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node); @@ -68517,13 +70461,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 206 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 161 /* Decorator */) { + else if (node.kind !== 162 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -68587,7 +70531,7 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 220 /* SpreadElement */ || arg.kind === 227 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 221 /* SpreadElement */ || arg.kind === 228 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -68604,9 +70548,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 === 205 /* TaggedTemplateExpression */) { + if (node.kind === 206 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 218 /* TemplateExpression */) { + if (node.template.kind === 219 /* 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. @@ -68621,7 +70565,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 161 /* Decorator */) { + else if (node.kind === 162 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -68635,7 +70579,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 204 /* NewExpression */); + ts.Debug.assert(node.kind === 205 /* NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -68710,7 +70654,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 64 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -68738,7 +70682,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 !== 161 /* Decorator */) { + if (node.kind !== 162 /* 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 @@ -68760,7 +70704,7 @@ var ts; instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 64 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of // the source type uses the outer context's return mapper (which excludes inferences made from @@ -68786,7 +70730,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 222 /* OmittedExpression */) { + if (arg.kind !== 223 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -68810,7 +70754,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 === 227 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 228 /* SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -68820,13 +70764,13 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 227 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 228 /* 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 === 220 /* SpreadElement */ ? arg.expression : arg)); + types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 221 /* SpreadElement */ ? arg.expression : arg)); flags.push(4 /* Rest */); } } @@ -68837,7 +70781,7 @@ var ts; types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); flags.push(1 /* Required */); } - if (arg.kind === 227 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 228 /* SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -68981,7 +70925,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 204 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 205 /* 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. @@ -68999,7 +70943,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 !== 222 /* OmittedExpression */) { + if (arg.kind !== 223 /* 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), @@ -69044,7 +70988,7 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 204 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); if (ts.isAccessExpression(callee)) { return callee.expression; @@ -69061,17 +71005,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 205 /* TaggedTemplateExpression */) { + if (node.kind === 206 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 218 /* TemplateExpression */) { + if (template.kind === 219 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 161 /* Decorator */) { + if (node.kind === 162 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -69082,10 +71026,10 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_20 = function (i) { + var _loop_21 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 220 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 221 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; @@ -69099,7 +71043,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_20(i); + _loop_21(i); } return effectiveArgs_1; } @@ -69112,30 +71056,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 222 /* 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 160 /* Parameter */: + case 161 /* 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 === 166 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 167 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 164 /* PropertyDeclaration */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* 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 !== 163 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 164 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -69149,17 +71093,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: return 1; - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: return 2; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* 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 160 /* Parameter */: + case 161 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -69205,77 +71149,66 @@ var ts; return constructorSymbol === globalPromiseSymbol; } function getArgumentArityError(node, signatures, args) { - var min = Number.POSITIVE_INFINITY; - var max = Number.NEGATIVE_INFINITY; - var belowArgCount = Number.NEGATIVE_INFINITY; - var aboveArgCount = Number.POSITIVE_INFINITY; - var argCount = args.length; + var _a; + var spreadIndex = getSpreadArgumentIndex(args); + if (spreadIndex > -1) { + return ts.createDiagnosticForNode(args[spreadIndex], ts.Diagnostics.A_spread_argument_must_either_have_a_tuple_type_or_be_passed_to_a_rest_parameter); + } + var min = Number.POSITIVE_INFINITY; // smallest parameter count + var max = Number.NEGATIVE_INFINITY; // largest parameter count + var maxBelow = Number.NEGATIVE_INFINITY; // largest parameter count that is smaller than the number of arguments + var minAbove = Number.POSITIVE_INFINITY; // smallest parameter count that is larger than the number of arguments var closestSignature; for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { var sig = signatures_8[_i]; - var minCount = getMinArgumentCount(sig); - var maxCount = getParameterCount(sig); - if (minCount < argCount && minCount > belowArgCount) - belowArgCount = minCount; - if (argCount < maxCount && maxCount < aboveArgCount) - aboveArgCount = maxCount; - if (minCount < min) { - min = minCount; + var minParameter = getMinArgumentCount(sig); + var maxParameter = getParameterCount(sig); + // smallest/largest parameter counts + if (minParameter < min) { + min = minParameter; closestSignature = sig; } - max = Math.max(max, maxCount); + max = Math.max(max, maxParameter); + // shortest parameter count *longer than the call*/longest parameter count *shorter than the call* + if (minParameter < args.length && minParameter > maxBelow) + maxBelow = minParameter; + if (args.length < maxParameter && maxParameter < minAbove) + minAbove = maxParameter; } var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter); - var paramRange = hasRestParameter ? min : - min < max ? min + "-" + max : - min; - var hasSpreadArgument = getSpreadArgumentIndex(args) > -1; - if (argCount <= max && hasSpreadArgument) { - argCount--; - } - var spanArray; - var related; - var error = hasRestParameter || hasSpreadArgument ? - hasRestParameter && hasSpreadArgument ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more : - hasRestParameter ? - ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 : - ts.Diagnostics.Expected_0_arguments_but_got_1_or_more : - paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ? - ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise : - ts.Diagnostics.Expected_0_arguments_but_got_1; - if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { - var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; - if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : - ts.isRestParameter(paramDecl) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); - } - } - if (min < argCount && argCount < max) { - return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount); - } - if (!hasSpreadArgument && argCount < min) { - var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1; - } - if (hasRestParameter || hasSpreadArgument) { - spanArray = ts.factory.createNodeArray(args); - if (hasSpreadArgument && argCount) { - var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined; - spanArray = ts.factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1))); + var parameterRange = hasRestParameter ? min + : min < max ? min + "-" + max + : min; + var error = hasRestParameter ? ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 + : parameterRange === 1 && args.length === 0 && isPromiseResolveArityError(node) ? ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise + : ts.Diagnostics.Expected_0_arguments_but_got_1; + if (min < args.length && args.length < max) { + // between min and max, but with no matching overload + return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, args.length, maxBelow, minAbove); + } + else if (args.length < min) { + // too short: put the error span on the call expression, not any of the args + var diagnostic = getDiagnosticForCallNode(node, error, parameterRange, args.length); + var parameter = (_a = closestSignature === null || closestSignature === void 0 ? void 0 : closestSignature.declaration) === null || _a === void 0 ? void 0 : _a.parameters[closestSignature.thisParameter ? args.length + 1 : args.length]; + if (parameter) { + var parameterError = ts.createDiagnosticForNode(parameter, ts.isBindingPattern(parameter.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided + : ts.isRestParameter(parameter) ? ts.Diagnostics.Arguments_for_the_rest_parameter_0_were_not_provided + : ts.Diagnostics.An_argument_for_0_was_not_provided, !parameter.name ? args.length : !ts.isBindingPattern(parameter.name) ? ts.idText(ts.getFirstIdentifier(parameter.name)) : undefined); + return ts.addRelatedInfo(diagnostic, parameterError); } + return diagnostic; } else { - spanArray = ts.factory.createNodeArray(args.slice(max)); - } - var pos = ts.first(spanArray).pos; - var end = ts.last(spanArray).end; - if (end === pos) { - end++; + // too long; error goes on the excess parameters + var errorSpan = ts.factory.createNodeArray(args.slice(max)); + var pos = ts.first(errorSpan).pos; + var end = ts.last(errorSpan).end; + if (end === pos) { + end++; + } + ts.setTextRangePosEnd(errorSpan, pos, end); + return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), errorSpan, error, parameterRange, args.length); } - ts.setTextRangePosEnd(spanArray, pos, end); - var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount); - return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic; } function getTypeArgumentArityError(node, signatures, typeArguments) { var argCount = typeArguments.length; @@ -69306,8 +71239,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 === 205 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 161 /* Decorator */; + var isTaggedTemplate = node.kind === 206 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 162 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray && produceDiagnostics; var typeArguments; @@ -69369,7 +71302,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 === 203 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 204 /* 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 @@ -69423,7 +71356,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_21 = function (c) { + var _loop_22 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -69441,7 +71374,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_21(c); + _loop_22(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -69599,7 +71532,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_22 = function (i) { + var _loop_23 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -69607,7 +71540,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_22(i); + _loop_23(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0 /* None */; @@ -69799,7 +71732,7 @@ var ts; function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 /* Union */ | 131072 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -69914,7 +71847,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 !== 166 /* Constructor */) { + if (!modifiers || declaration.kind !== 167 /* Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -70058,16 +71991,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 160 /* Parameter */: + case 161 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -70162,16 +72095,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 203 /* CallExpression */: + case 204 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 204 /* NewExpression */: + case 205 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 161 /* Decorator */: + case 162 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxOpeningElement */: + case 275 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -70303,7 +72236,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 201 /* PropertyAccessExpression */) { + while (parent && parent.kind === 202 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { @@ -70330,12 +72263,12 @@ var ts; if (node.expression.kind === 105 /* SuperKeyword */) { return voidType; } - if (node.kind === 204 /* NewExpression */) { + if (node.kind === 205 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 166 /* Constructor */ && - declaration.kind !== 170 /* ConstructSignature */ && - declaration.kind !== 175 /* ConstructorType */ && + declaration.kind !== 167 /* Constructor */ && + declaration.kind !== 171 /* ConstructSignature */ && + declaration.kind !== 176 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -70355,7 +72288,7 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 203 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 233 /* ExpressionStatement */ && + if (node.kind === 204 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 234 /* 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); @@ -70369,7 +72302,7 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); - jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + jsAssignmentType.objectFlags |= 8192 /* JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } @@ -70385,20 +72318,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 203 /* CallExpression */: - case 161 /* Decorator */: - case 204 /* NewExpression */: + case 204 /* CallExpression */: + case 162 /* Decorator */: + case 205 /* NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxOpeningElement */: + case 275 /* JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: return node.argumentExpression; - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return node.name; - case 173 /* TypeReference */: + case 174 /* TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -70449,10 +72382,11 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { + var _a; if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { - var file = ts.find(originalSymbol.declarations, ts.isSourceFile); + var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false); if (hasSyntheticDefault) { var memberTable = ts.createSymbolTable(); @@ -70490,9 +72424,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 251 /* FunctionDeclaration */ + ? 252 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 249 /* VariableDeclaration */ + ? 250 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -70522,19 +72456,19 @@ var ts; case 9 /* BigIntLiteral */: case 109 /* TrueKeyword */: case 94 /* FalseKeyword */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 218 /* TemplateExpression */: + case 200 /* ArrayLiteralExpression */: + case 201 /* ObjectLiteralExpression */: + case 219 /* TemplateExpression */: return true; - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 214 /* PrefixUnaryExpression */: + case 215 /* 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 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -70590,7 +72524,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 === 166 /* Constructor */) { + else if (container.kind === 167 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -70637,7 +72571,7 @@ var ts; return restParameter.escapedName; } function isValidDeclarationForTupleLabel(d) { - return d.kind === 192 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 193 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -70802,7 +72736,14 @@ var ts; } } function assignContextualParameterTypes(signature, context) { - signature.typeParameters = context.typeParameters; + if (context.typeParameters) { + if (!signature.typeParameters) { + signature.typeParameters = context.typeParameters; + } + else { + return; // This signature has already has a contextual inference performed and cached on it! + } + } if (context.thisParameter) { var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { @@ -70913,7 +72854,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 230 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 231 /* 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 @@ -71098,7 +73039,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 211 /* TypeOfExpression */) { + if (node.expression.kind === 212 /* 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. @@ -71161,11 +73102,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return true; - case 165 /* MethodDeclaration */: - return func.parent.kind === 200 /* ObjectLiteralExpression */; + case 166 /* MethodDeclaration */: + return func.parent.kind === 201 /* ObjectLiteralExpression */; default: return false; } @@ -71191,21 +73132,21 @@ 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 === 164 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 230 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 165 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 231 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var errorNode = ts.getEffectiveReturnTypeNode(func) || func; if (type && type.flags & 131072 /* Never */) { - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); + error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { // minimal check: function has syntactic return type annotation and no explicit return statements in the body // this function does not conform to the specification. - // NOTE: having returnType !== undefined is a precondition for entering this branch so func.type will always be present - error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); + error(errorNode, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) { - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); + error(errorNode, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined); } else if (compilerOptions.noImplicitReturns) { if (!type) { @@ -71220,11 +73161,11 @@ var ts; return; } } - error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value); + error(errorNode, ts.Diagnostics.Not_all_code_paths_return_a_value); } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 166 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -71240,7 +73181,7 @@ var ts; var returnType = getReturnTypeFromBody(node, checkMode); var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); - returnOnlyType.objectFlags |= 2097152 /* NonInferrableType */; + returnOnlyType.objectFlags |= 524288 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -71248,7 +73189,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 208 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 209 /* FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -71294,7 +73235,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 165 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 166 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -71307,7 +73248,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 230 /* Block */) { + if (node.body.kind === 231 /* Block */) { checkSourceElement(node.body); } else { @@ -71397,7 +73338,7 @@ var ts; expr.expression.kind === 107 /* 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 === 166 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 167 /* Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -71422,7 +73363,7 @@ var ts; var symbol_2 = getNodeLinks(node).resolvedSymbol; if (symbol_2.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 263 /* NamespaceImport */; + return !!declaration && declaration.kind === 264 /* NamespaceImport */; } } } @@ -71503,7 +73444,7 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(node); - if (func && func.kind !== 166 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { + if (func && func.kind !== 167 /* Constructor */ && (ts.getFunctionFlags(func) & 2 /* Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -71715,7 +73656,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 288 /* PropertyAssignment */ || property.kind === 289 /* ShorthandPropertyAssignment */) { + if (property.kind === 289 /* PropertyAssignment */ || property.kind === 290 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -71723,14 +73664,14 @@ var ts; var prop = getPropertyOfType(objectLiteralType, text); if (prop) { markPropertyAsReferenced(prop, property, rightIsThis); - checkPropertyAccessibility(property, /*isSuper*/ false, objectLiteralType, prop); + checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } var elementType = getIndexedAccessType(objectLiteralType, exprType, /*noUncheckedIndexedAccessCandidate*/ undefined, name, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, 16 /* ExpressionPosition */); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 289 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 290 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 290 /* SpreadAssignment */) { + else if (property.kind === 291 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -71768,7 +73709,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 === 220 /* SpreadElement */) { + if (node.elements[i].kind === 221 /* SpreadElement */) { type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); @@ -71778,8 +73719,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 222 /* OmittedExpression */) { - if (element.kind !== 220 /* SpreadElement */) { + if (element.kind !== 223 /* OmittedExpression */) { + if (element.kind !== 221 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -71797,7 +73738,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 216 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { + if (restExpression.kind === 217 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -71813,7 +73754,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 289 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 290 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -71829,24 +73770,24 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 216 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { + if (target.kind === 217 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 200 /* ObjectLiteralExpression */) { + if (target.kind === 201 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 199 /* ArrayLiteralExpression */) { + if (target.kind === 200 /* 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 === 290 /* SpreadAssignment */ ? + var error = target.parent.kind === 291 /* 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 === 290 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 291 /* 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)) { @@ -71871,8 +73812,8 @@ var ts; case 78 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 205 /* TaggedTemplateExpression */: - case 218 /* TemplateExpression */: + case 206 /* TaggedTemplateExpression */: + case 219 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: @@ -71880,27 +73821,27 @@ var ts; case 94 /* FalseKeyword */: case 103 /* NullKeyword */: case 150 /* UndefinedKeyword */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: - case 209 /* ArrowFunction */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 211 /* TypeOfExpression */: - case 225 /* NonNullExpression */: - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: + case 209 /* FunctionExpression */: + case 222 /* ClassExpression */: + case 210 /* ArrowFunction */: + case 200 /* ArrayLiteralExpression */: + case 201 /* ObjectLiteralExpression */: + case 212 /* TypeOfExpression */: + case 226 /* NonNullExpression */: + case 275 /* JsxSelfClosingElement */: + case 274 /* JsxElement */: return true; - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -71912,9 +73853,9 @@ var ts; } return false; // Some forms listed here for clarity - case 212 /* VoidExpression */: // Explicit opt-out - case 206 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 224 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 213 /* VoidExpression */: // Explicit opt-out + case 207 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 225 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -71922,84 +73863,111 @@ var ts; function isTypeEqualityComparableTo(source, target) { return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } - var CheckBinaryExpressionState; - (function (CheckBinaryExpressionState) { - CheckBinaryExpressionState[CheckBinaryExpressionState["MaybeCheckLeft"] = 0] = "MaybeCheckLeft"; - CheckBinaryExpressionState[CheckBinaryExpressionState["CheckRight"] = 1] = "CheckRight"; - CheckBinaryExpressionState[CheckBinaryExpressionState["FinishCheck"] = 2] = "FinishCheck"; - })(CheckBinaryExpressionState || (CheckBinaryExpressionState = {})); - function checkBinaryExpression(node, checkMode) { - var workStacks = { - expr: [node], - state: [0 /* MaybeCheckLeft */], - leftType: [undefined] + function createCheckBinaryExpression() { + var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); + return function (node, checkMode) { + var result = trampoline(node, checkMode); + ts.Debug.assertIsDefined(result); + return result; }; - var stackIndex = 0; - var lastResult; - while (stackIndex >= 0) { - node = workStacks.expr[stackIndex]; - switch (workStacks.state[stackIndex]) { - case 0 /* MaybeCheckLeft */: { - if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { - finishInvocation(checkExpression(node.right, checkMode)); - break; - } - checkGrammarNullishCoalesceWithLogicalExpression(node); - var operator = node.operatorToken.kind; - if (operator === 62 /* EqualsToken */ && (node.left.kind === 200 /* ObjectLiteralExpression */ || node.left.kind === 199 /* ArrayLiteralExpression */)) { - finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107 /* ThisKeyword */)); - break; - } - advanceState(1 /* CheckRight */); - maybeCheckExpression(node.left); - break; - } - case 1 /* CheckRight */: { - var leftType = lastResult; - workStacks.leftType[stackIndex] = leftType; - var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); - checkTestingKnownTruthyCallableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); - } - checkTruthinessOfType(leftType, node.left); + function onEnter(node, state, checkMode) { + if (state) { + state.stackIndex++; + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + } + else { + state = { + checkMode: checkMode, + skip: false, + stackIndex: 0, + typeStack: [undefined, undefined], + }; + } + if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { + state.skip = true; + setLastResult(state, checkExpression(node.right, checkMode)); + return state; + } + checkGrammarNullishCoalesceWithLogicalExpression(node); + var operator = node.operatorToken.kind; + if (operator === 62 /* EqualsToken */ && (node.left.kind === 201 /* ObjectLiteralExpression */ || node.left.kind === 200 /* ArrayLiteralExpression */)) { + state.skip = true; + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107 /* ThisKeyword */)); + return state; + } + return state; + } + function onLeft(left, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, left); + } + } + function onOperator(operatorToken, state, node) { + if (!state.skip) { + var leftType = getLastResult(state); + ts.Debug.assertIsDefined(leftType); + setLeftType(state, leftType); + setLastResult(state, /*type*/ undefined); + var operator = operatorToken.kind; + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* AmpersandAmpersandToken */) { + var parent = ts.walkUpParenthesizedExpressions(node.parent); + checkTestingKnownTruthyCallableOrAwaitableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } - advanceState(2 /* FinishCheck */); - maybeCheckExpression(node.right); - break; - } - case 2 /* FinishCheck */: { - var leftType = workStacks.leftType[stackIndex]; - var rightType = lastResult; - finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node)); - break; + checkTruthinessOfType(leftType, node.left); } - default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression"); } } - return lastResult; - function finishInvocation(result) { - lastResult = result; - stackIndex--; - } - /** - * Note that `advanceState` sets the _current_ head state, and that `maybeCheckExpression` potentially pushes on a new - * head state; so `advanceState` must be called before any `maybeCheckExpression` during a state's execution. - */ - function advanceState(nextState) { - workStacks.state[stackIndex] = nextState; + function onRight(right, state, _node) { + if (!state.skip) { + return maybeCheckExpression(state, right); + } } - function maybeCheckExpression(node) { - if (ts.isBinaryExpression(node)) { - stackIndex++; - workStacks.expr[stackIndex] = node; - workStacks.state[stackIndex] = 0 /* MaybeCheckLeft */; - workStacks.leftType[stackIndex] = undefined; + function onExit(node, state) { + var result; + if (state.skip) { + result = getLastResult(state); } else { - lastResult = checkExpression(node, checkMode); + var leftType = getLeftType(state); + ts.Debug.assertIsDefined(leftType); + var rightType = getLastResult(state); + ts.Debug.assertIsDefined(rightType); + result = checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node); + } + state.skip = false; + setLeftType(state, /*type*/ undefined); + setLastResult(state, /*type*/ undefined); + state.stackIndex--; + return result; + } + function foldState(state, result, _side) { + setLastResult(state, result); + return state; + } + function maybeCheckExpression(state, node) { + if (ts.isBinaryExpression(node)) { + return node; } + setLastResult(state, checkExpression(node, state.checkMode)); + } + function getLeftType(state) { + return state.typeStack[state.stackIndex]; + } + function setLeftType(state, type) { + state.typeStack[state.stackIndex] = type; + } + function getLastResult(state) { + return state.typeStack[state.stackIndex + 1]; + } + function setLastResult(state, type) { + // To reduce overhead, reuse the next stack entry to store the + // last result. This avoids the overhead of an additional property + // on `WorkArea` and reuses empty stack entries as we walk back up + // the stack. + state.typeStack[state.stackIndex + 1] = type; } } function checkGrammarNullishCoalesceWithLogicalExpression(node) { @@ -72017,7 +73985,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 === 62 /* EqualsToken */ && (left.kind === 200 /* ObjectLiteralExpression */ || left.kind === 199 /* ArrayLiteralExpression */)) { + if (operator === 62 /* EqualsToken */ && (left.kind === 201 /* ObjectLiteralExpression */ || left.kind === 200 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107 /* ThisKeyword */); } var leftType; @@ -72252,7 +74220,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); - if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); } @@ -72447,7 +74415,7 @@ var ts; } function checkConditionalExpression(node, checkMode) { var type = checkTruthinessExpression(node.condition); - checkTestingKnownTruthyCallableType(node.condition, type, node.whenTrue); + checkTestingKnownTruthyCallableOrAwaitableType(node.condition, type, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); return getUnionType([type1, type2], 2 /* Subtype */); @@ -72464,10 +74432,14 @@ var ts; texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return isConstContext(node) ? getTemplateLiteralType(texts, types) : stringType; + return isConstContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; + } + function isTemplateLiteralContextualType(type) { + return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || + type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); } function getContextNode(node) { - if (node.kind === 281 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 282 /* 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; @@ -72516,13 +74488,13 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 206 /* TypeAssertionExpression */ || node.kind === 224 /* AsExpression */; + return node.kind === 207 /* TypeAssertionExpression */ || node.kind === 225 /* AsExpression */; } function checkDeclarationInitializer(declaration, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, 0 /* Normal */) : checkExpressionCached(initializer)); - return ts.isParameter(declaration) && declaration.name.kind === 197 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 198 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -72532,7 +74504,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 === 198 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 199 /* 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)) { @@ -72599,7 +74571,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 159 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -72610,7 +74582,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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 159 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -72846,11 +74818,11 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 201 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 202 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 78 /* Identifier */ || node.kind === 157 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 176 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 270 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 202 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 203 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 78 /* Identifier */ || node.kind === 158 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 177 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 271 /* ExportSpecifier */); // We allow reexporting const enums 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); } @@ -72875,15 +74847,15 @@ 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 222 /* ClassExpression */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { case 78 /* Identifier */: - return checkIdentifier(node); + return checkIdentifier(node, checkMode); case 107 /* ThisKeyword */: return checkThisExpression(node); case 105 /* SuperKeyword */: @@ -72903,78 +74875,78 @@ var ts; return trueType; case 94 /* FalseKeyword */: return falseType; - case 218 /* TemplateExpression */: + case 219 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 201 /* PropertyAccessExpression */: - return checkPropertyAccessExpression(node); - case 157 /* QualifiedName */: - return checkQualifiedName(node); - case 202 /* ElementAccessExpression */: - return checkIndexedAccess(node); - case 203 /* CallExpression */: + case 202 /* PropertyAccessExpression */: + return checkPropertyAccessExpression(node, checkMode); + case 158 /* QualifiedName */: + return checkQualifiedName(node, checkMode); + case 203 /* ElementAccessExpression */: + return checkIndexedAccess(node, checkMode); + case 204 /* CallExpression */: if (node.expression.kind === 99 /* ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 204 /* NewExpression */: + case 205 /* NewExpression */: return checkCallExpression(node, checkMode); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 221 /* ClassExpression */: + case 222 /* ClassExpression */: return checkClassExpression(node); - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 211 /* TypeOfExpression */: + case 212 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 207 /* TypeAssertionExpression */: + case 225 /* AsExpression */: return checkAssertion(node); - case 225 /* NonNullExpression */: + case 226 /* NonNullExpression */: return checkNonNullAssertion(node); - case 226 /* MetaProperty */: + case 227 /* MetaProperty */: return checkMetaProperty(node); - case 210 /* DeleteExpression */: + case 211 /* DeleteExpression */: return checkDeleteExpression(node); - case 212 /* VoidExpression */: + case 213 /* VoidExpression */: return checkVoidExpression(node); - case 213 /* AwaitExpression */: + case 214 /* AwaitExpression */: return checkAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 220 /* SpreadElement */: + case 221 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 222 /* OmittedExpression */: + case 223 /* OmittedExpression */: return undefinedWideningType; - case 219 /* YieldExpression */: + case 220 /* YieldExpression */: return checkYieldExpression(node); - case 227 /* SyntheticExpression */: + case 228 /* SyntheticExpression */: return checkSyntheticExpression(node); - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 273 /* JsxElement */: + case 274 /* JsxElement */: return checkJsxElement(node, checkMode); - case 274 /* JsxSelfClosingElement */: + case 275 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 277 /* JsxFragment */: + case 278 /* JsxFragment */: return checkJsxFragment(node); - case 281 /* JsxAttributes */: + case 282 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 275 /* JsxOpeningElement */: + case 276 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -73010,11 +74982,11 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 166 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!(func.kind === 167 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 166 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 167 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } @@ -73025,13 +74997,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 === 166 /* Constructor */ || func.kind === 170 /* ConstructSignature */ || func.kind === 175 /* ConstructorType */) { + if (func.kind === 167 /* Constructor */ || func.kind === 171 /* ConstructSignature */ || func.kind === 176 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 209 /* ArrowFunction */) { + if (func.kind === 210 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 167 /* GetAccessor */ || func.kind === 168 /* SetAccessor */) { + if (func.kind === 168 /* GetAccessor */ || func.kind === 169 /* SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -73089,13 +75061,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 209 /* ArrowFunction */: - case 169 /* CallSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 174 /* FunctionType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 210 /* ArrowFunction */: + case 170 /* CallSignature */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 175 /* FunctionType */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -73113,7 +75085,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 === 197 /* ArrayBindingPattern */ || name.kind === 196 /* ObjectBindingPattern */) { + else if (name.kind === 198 /* ArrayBindingPattern */ || name.kind === 197 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -73122,13 +75094,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 172 /* 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 === 174 /* FunctionType */ || node.kind === 251 /* FunctionDeclaration */ || node.kind === 175 /* ConstructorType */ || - node.kind === 169 /* CallSignature */ || node.kind === 166 /* Constructor */ || - node.kind === 170 /* ConstructSignature */) { + else if (node.kind === 175 /* FunctionType */ || node.kind === 252 /* FunctionDeclaration */ || node.kind === 176 /* ConstructorType */ || + node.kind === 170 /* CallSignature */ || node.kind === 167 /* Constructor */ || + node.kind === 171 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -73158,10 +75130,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 170 /* ConstructSignature */: + case 171 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 169 /* CallSignature */: + case 170 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -73191,7 +75163,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 171 /* IndexSignature */ && node.kind !== 308 /* JSDocFunctionType */) { + if (node.kind !== 172 /* IndexSignature */ && node.kind !== 309 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -73203,7 +75175,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 === 166 /* Constructor */) { + if (member.kind === 167 /* 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)) { @@ -73215,25 +75187,27 @@ var ts; var isStatic = ts.hasSyntacticModifier(member, 32 /* Static */); var name = member.name; if (!name) { - return; + continue; } - var names = ts.isPrivateIdentifier(name) ? privateIdentifiers : + var isPrivate = ts.isPrivateIdentifier(name); + var privateStaticFlags = isPrivate && isStatic ? 16 /* PrivateStatic */ : 0; + var names = isPrivate ? privateIdentifiers : isStatic ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 167 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */); + case 168 /* GetAccessor */: + addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); break; - case 168 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */); + case 169 /* SetAccessor */: + addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); break; - case 163 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */); + case 164 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); break; - case 165 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */); + case 166 /* MethodDeclaration */: + addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); break; } } @@ -73242,16 +75216,25 @@ var ts; function addName(names, location, name, meaning) { var prev = names.get(name); if (prev) { - if (prev & 8 /* Method */) { - if (meaning !== 8 /* Method */) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); - } - } - else if (prev & meaning) { - error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + // For private identifiers, do not allow mixing of static and instance members with the same name + if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - names.set(name, prev | meaning); + var prevIsMethod = !!(prev & 8 /* Method */); + var isMethod = !!(meaning & 8 /* Method */); + if (prevIsMethod || isMethod) { + if (prevIsMethod !== isMethod) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered + } + else if (prev & meaning & ~16 /* PrivateStatic */) { + error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); + } + else { + names.set(name, prev | meaning); + } } } else { @@ -73295,7 +75278,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 === 162 /* PropertySignature */) { + if (member.kind === 163 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -73320,11 +75303,11 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 254 /* 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 - if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { + if (nodeSymbol.declarations && nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; } } @@ -73332,7 +75315,7 @@ var ts; // 3.7.4: An object type can contain at most one string index signature and one numeric index signature. // 8.5: A class declaration can have at most one string index member declaration and one numeric index member declaration var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); - if (indexSymbol) { + if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var seenNumericIndexer = false; var seenStringIndexer = false; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -73366,11 +75349,9 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node)) checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); - // Private class fields transformation relies on WeakMaps. - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { - for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; - } + setNodeLinksForPrivateIdentifierScope(node); + if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) { + error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag); } } function checkPropertySignature(node) { @@ -73383,16 +75364,35 @@ var ts; // Grammar checking if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); - if (ts.isPrivateIdentifier(node.name)) { - error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier); - } // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 165 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* 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 + if (ts.isPrivateIdentifier(node.name) && !ts.getContainingClass(node)) { + error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + } + setNodeLinksForPrivateIdentifierScope(node); + } + function setNodeLinksForPrivateIdentifierScope(node) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { + getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + } + // If this is a private element in a class expression inside the body of a loop, + // then we must use a block-scoped binding to store the additional variables required + // to transform private elements. + if (ts.isClassExpression(node.parent)) { + var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); + if (enclosingIterationStatement) { + getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + } + } + } } function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. @@ -73415,10 +75415,10 @@ var ts; return; } function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) { - if (ts.isPrivateIdentifierPropertyDeclaration(n)) { + if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 163 /* PropertyDeclaration */ && + return n.kind === 164 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(n, 32 /* Static */) && !!n.initializer; } @@ -73439,9 +75439,9 @@ 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 */ || !compilerOptions.useDefineForClassFields) && + var superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 92 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { @@ -73449,7 +75449,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 === 233 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 234 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -73474,7 +75474,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 168 /* 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); @@ -73484,45 +75484,42 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 159 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } - if (ts.isPrivateIdentifier(node.name)) { - error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier); - } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; - var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); - if (otherAccessor) { - var nodeFlags = ts.getEffectiveModifierFlags(node); - var otherFlags = ts.getEffectiveModifierFlags(otherAccessor); - if ((nodeFlags & 28 /* AccessibilityModifier */) !== (otherFlags & 28 /* AccessibilityModifier */)) { - error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); + var symbol = getSymbolOfNode(node); + var getter = ts.getDeclarationOfKind(symbol, 168 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 169 /* SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getterFlags = ts.getEffectiveModifierFlags(getter); + var setterFlags = ts.getEffectiveModifierFlags(setter); + if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if ((nodeFlags & 128 /* Abstract */) !== (otherFlags & 128 /* Abstract */)) { - error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); + if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || + ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); + error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); + } + var getterType = getAnnotatedAccessorType(getter); + var setterType = getAnnotatedAccessorType(setter); + if (getterType && setterType) { + checkTypeAssignableTo(getterType, setterType, getter, ts.Diagnostics.The_return_type_of_a_get_accessor_must_be_assignable_to_its_set_accessor_type); } - // TypeScript 1.0 spec (April 2014): 4.5 - // If both accessors include type annotations, the specified types must be identical. - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type); - checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 168 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } checkSourceElement(node.body); - } - function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { - var firstType = getAnnotatedType(first); - var secondType = getAnnotatedType(second); - if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) { - error(first, message); - } + setNodeLinksForPrivateIdentifierScope(node); } function checkMissingDeclaration(node) { checkDecorators(node); @@ -73559,7 +75556,7 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 173 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 174 /* 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); @@ -73612,7 +75609,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 !== 192 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 193 /* NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } @@ -73661,7 +75658,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 202 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 203 /* 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)); } @@ -73719,7 +75716,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 185 /* 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); @@ -73742,25 +75739,25 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 180 /* OptionalType */) { + if (node.type.kind === 181 /* 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 === 181 /* RestType */) { + if (node.type.kind === 182 /* 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); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { 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 !== 253 /* InterfaceDeclaration */ && - n.parent.kind !== 252 /* ClassDeclaration */ && - n.parent.kind !== 221 /* ClassExpression */ && + if (n.parent.kind !== 254 /* InterfaceDeclaration */ && + n.parent.kind !== 253 /* ClassDeclaration */ && + n.parent.kind !== 222 /* 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 @@ -73856,7 +75853,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 === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */) && + var reportError = (node.kind === 166 /* MethodDeclaration */ || node.kind === 165 /* MethodSignature */) && ts.hasSyntacticModifier(node, 32 /* Static */) !== ts.hasSyntacticModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -73893,55 +75890,57 @@ var ts; var multipleConstructorImplementation = false; var hasNonAmbientClass = false; var functionDeclarations = []; - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var current = declarations_4[_i]; - var node = current; - var inAmbientContext = node.flags & 8388608 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 /* InterfaceDeclaration */ || node.parent.kind === 177 /* TypeLiteral */) || inAmbientContext; - if (inAmbientContextOrInterface) { - // check if declarations are consecutive only if they are non-ambient - // 1. ambient declarations can be interleaved - // i.e. this is legal - // declare function foo(); - // declare function bar(); - // declare function foo(); - // 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 === 252 /* ClassDeclaration */ || node.kind === 221 /* ClassExpression */) && !inAmbientContext) { - hasNonAmbientClass = true; - } - if (node.kind === 251 /* FunctionDeclaration */ || node.kind === 165 /* MethodDeclaration */ || node.kind === 164 /* MethodSignature */ || node.kind === 166 /* Constructor */) { - functionDeclarations.push(node); - var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); - someNodeFlags |= currentNodeFlags; - allNodeFlags &= currentNodeFlags; - someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); - allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); - var bodyIsPresent = ts.nodeIsPresent(node.body); - if (bodyIsPresent && bodyDeclaration) { - if (isConstructor) { - multipleConstructorImplementation = true; + if (declarations) { + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; + var node = current; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 254 /* InterfaceDeclaration */ || node.parent.kind === 178 /* TypeLiteral */) || inAmbientContext; + if (inAmbientContextOrInterface) { + // check if declarations are consecutive only if they are non-ambient + // 1. ambient declarations can be interleaved + // i.e. this is legal + // declare function foo(); + // declare function bar(); + // declare function foo(); + // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one + previousDeclaration = undefined; + } + if ((node.kind === 253 /* ClassDeclaration */ || node.kind === 222 /* ClassExpression */) && !inAmbientContext) { + hasNonAmbientClass = true; + } + if (node.kind === 252 /* FunctionDeclaration */ || node.kind === 166 /* MethodDeclaration */ || node.kind === 165 /* MethodSignature */ || node.kind === 167 /* Constructor */) { + functionDeclarations.push(node); + var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); + someNodeFlags |= currentNodeFlags; + allNodeFlags &= currentNodeFlags; + someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node); + allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node); + var bodyIsPresent = ts.nodeIsPresent(node.body); + if (bodyIsPresent && bodyDeclaration) { + if (isConstructor) { + multipleConstructorImplementation = true; + } + else { + duplicateFunctionDeclaration = true; + } + } + else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { + reportImplementationExpectedError(previousDeclaration); + } + if (bodyIsPresent) { + if (!bodyDeclaration) { + bodyDeclaration = node; + } } else { - duplicateFunctionDeclaration = true; + hasOverloads = true; } - } - else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) { - reportImplementationExpectedError(previousDeclaration); - } - if (bodyIsPresent) { - if (!bodyDeclaration) { - bodyDeclaration = node; + previousDeclaration = node; + if (!inAmbientContextOrInterface) { + lastSeenNonAmbientDeclaration = node; } } - else { - hasOverloads = true; - } - previousDeclaration = node; - if (!inAmbientContextOrInterface) { - lastSeenNonAmbientDeclaration = node; - } } } if (multipleConstructorImplementation) { @@ -73969,8 +75968,10 @@ var ts; reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { - checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); - checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + if (declarations) { + checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags); + checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken); + } if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); @@ -74044,43 +76045,46 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 335 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: + case 329 /* JSDocEnumTag */: return 2 /* ExportType */; - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: + case 253 /* ClassDeclaration */: + case 256 /* EnumDeclaration */: + case 292 /* EnumMember */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 297 /* SourceFile */: + case 298 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: + case 217 /* 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 - if (!ts.isEntityNameExpression(d.expression)) { + if (!ts.isEntityNameExpression(expression)) { return 1 /* ExportValue */; } - d = d.expression; + d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 262 /* ImportClause */: - var result_12 = 0 /* None */; + case 261 /* ImportEqualsDeclaration */: + case 264 /* NamespaceImport */: + case 263 /* ImportClause */: + var result_13 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); - return result_12; - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: - case 251 /* FunctionDeclaration */: - case 265 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + ts.forEach(target.declarations, function (d) { result_13 |= getDeclarationSpaces(d); }); + return result_13; + case 250 /* VariableDeclaration */: + case 199 /* BindingElement */: + case 252 /* FunctionDeclaration */: + case 266 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 case 78 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` @@ -74373,24 +76377,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 160 /* Parameter */: + case 161 /* 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 163 /* PropertyDeclaration */: + case 164 /* 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 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -74437,15 +76441,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 184 /* IntersectionType */: + case 183 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 184 /* ConditionalType */: + case 185 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 186 /* ParenthesizedType */: - case 192 /* NamedTupleMember */: + case 187 /* ParenthesizedType */: + case 193 /* NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 173 /* TypeReference */: + case 174 /* TypeReference */: return node.typeName; } } @@ -74454,13 +76458,13 @@ var ts; var commonEntityName; for (var _i = 0, types_23 = types; _i < types_23.length; _i++) { var typeNode = types_23[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */ || typeNode.kind === 192 /* NamedTupleMember */) { + while (typeNode.kind === 187 /* ParenthesizedType */ || typeNode.kind === 193 /* NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 141 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 192 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* 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); @@ -74506,14 +76510,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 160 /* Parameter */) { + if (node.kind === 161 /* 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 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -74522,23 +76526,23 @@ var ts; } } break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - var otherKind = node.kind === 167 /* GetAccessor */ ? 168 /* SetAccessor */ : 167 /* GetAccessor */; + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + var otherKind = node.kind === 168 /* GetAccessor */ ? 169 /* SetAccessor */ : 168 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 165 /* MethodDeclaration */: + case 166 /* 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 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 160 /* Parameter */: + case 161 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -74601,7 +76605,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 === 157 /* 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 === 158 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -74645,20 +76649,21 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return node; - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return node.name; default: return undefined; } } function checkFunctionOrMethodDeclaration(node) { + var _a; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); // 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 === 158 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 159 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -74672,7 +76677,7 @@ var ts; // Since the javascript won't do semantic analysis like typescript, // if the javascript file comes before the typescript file and both contain same name functions, // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. - var firstDeclaration = ts.find(localSymbol.declarations, + var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once @@ -74684,7 +76689,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 164 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 165 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -74726,42 +76731,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 297 /* SourceFile */: - case 256 /* ModuleDeclaration */: - case 230 /* Block */: - case 258 /* CaseBlock */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 298 /* SourceFile */: + case 257 /* ModuleDeclaration */: + case 231 /* Block */: + case 259 /* CaseBlock */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 167 /* Constructor */: + case 209 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 210 /* ArrowFunction */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: + case 165 /* MethodSignature */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: + case 255 /* TypeAliasDeclaration */: + case 254 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 185 /* InferType */: + case 186 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -74781,11 +76786,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 165 /* MethodDeclaration */: - case 163 /* PropertyDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - if (member.kind === 168 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 166 /* MethodDeclaration */: + case 164 /* PropertyDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + if (member.kind === 169 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -74796,7 +76801,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 166 /* Constructor */: + case 167 /* 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 */)) { @@ -74804,8 +76809,8 @@ var ts; } } break; - case 171 /* IndexSignature */: - case 229 /* SemicolonClassElement */: + case 172 /* IndexSignature */: + case 230 /* SemicolonClassElement */: // Can't be private break; default: @@ -74822,7 +76827,8 @@ var ts; function checkUnusedTypeParameters(node, addDiagnostic) { // Only report errors on the last declaration for the type parameter container; // this ensures that all uses have been accounted for. - if (ts.last(getSymbolOfNode(node).declarations) !== node) + var declarations = getSymbolOfNode(node).declarations; + if (!declarations || ts.last(declarations) !== node) return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); @@ -74832,7 +76838,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 185 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 186 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -74892,39 +76898,41 @@ var ts; if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { return; } - for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (isValidUnusedLocalDeclaration(declaration)) { - continue; - } - if (isImportedDeclaration(declaration)) { - addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); - } - else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { - // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. - var lastElement = ts.last(declaration.parent.elements); - if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { - addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); + if (local.declarations) { + for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (isValidUnusedLocalDeclaration(declaration)) { + continue; } - } - else if (ts.isVariableDeclaration(declaration)) { - addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); - } - else { - var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); - var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); - if (parameter && name) { - if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { - if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { - addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); - } - else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); - } + if (isImportedDeclaration(declaration)) { + addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId); + } + else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) { + // In `{ a, ...b }, `a` is considered used since it removes a property from `b`. `b` may still be unused though. + var lastElement = ts.last(declaration.parent.elements); + if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) { + addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } else { - errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); + var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration); + if (parameter && name) { + if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) { + if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) { + addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); + } + else { + addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + } + } + } + else { + errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic); + } } } } @@ -74934,7 +76942,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 263 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 264 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -74952,7 +76960,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 === 249 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 250 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 250 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 251 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -74973,7 +76981,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 === 232 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 233 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -74987,22 +76995,22 @@ var ts; switch (name.kind) { case 78 /* Identifier */: return ts.idText(name); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 198 /* ArrayBindingPattern */: + case 197 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 262 /* ImportClause */ || node.kind === 265 /* ImportSpecifier */ || node.kind === 263 /* NamespaceImport */; + return node.kind === 263 /* ImportClause */ || node.kind === 266 /* ImportSpecifier */ || node.kind === 264 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 262 /* ImportClause */ ? decl : decl.kind === 263 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 263 /* ImportClause */ ? decl : decl.kind === 264 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 230 /* Block */) { + if (node.kind === 231 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -75032,12 +77040,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 163 /* PropertyDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 165 /* MethodDeclaration */ || - node.kind === 164 /* MethodSignature */ || - node.kind === 167 /* GetAccessor */ || - node.kind === 168 /* SetAccessor */) { + if (node.kind === 164 /* PropertyDeclaration */ || + node.kind === 163 /* PropertySignature */ || + node.kind === 166 /* MethodDeclaration */ || + node.kind === 165 /* MethodSignature */ || + node.kind === 168 /* GetAccessor */ || + node.kind === 169 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -75046,7 +77054,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 160 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 161 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -75083,10 +77091,11 @@ var ts; return false; }); } - function checkWeakMapCollision(node) { + function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { - errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap"); + ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); + errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -75103,7 +77112,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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 298 /* 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)); } @@ -75118,7 +77127,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 === 297 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 298 /* 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)); } @@ -75153,7 +77162,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 === 249 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 250 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -75165,17 +77174,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 232 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 251 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 233 /* 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 === 230 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 257 /* ModuleBlock */ || - container.kind === 256 /* ModuleDeclaration */ || - container.kind === 297 /* SourceFile */); + (container.kind === 231 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 258 /* ModuleBlock */ || + container.kind === 257 /* ModuleDeclaration */ || + container.kind === 298 /* 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 @@ -75206,18 +77215,18 @@ 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 === 158 /* ComputedPropertyName */) { + if (node.name.kind === 159 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 198 /* BindingElement */) { - if (node.parent.kind === 196 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (ts.isBindingElement(node)) { + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 158 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 159 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -75230,15 +77239,15 @@ var ts; var nameText = getPropertyNameFromType(exprType); var property = getPropertyOfType(parentType, nameText); if (property) { - markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 105 /* SuperKeyword */, parentType, property); + markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 105 /* SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 197 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 198 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); @@ -75250,7 +77259,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 !== 238 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 239 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -75278,7 +77287,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node, /*requireStringLiteralLikeArgument*/ true)) { + if (symbol.flags & 2097152 /* Alias */ && ts.isRequireVariableDeclaration(node)) { checkAliasSymbol(node); return; } @@ -75292,11 +77301,11 @@ 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 !== 238 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 239 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } - if (symbol.declarations.length > 1) { + if (symbol.declarations && symbol.declarations.length > 1) { if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } @@ -75314,26 +77323,27 @@ var ts; if (node.initializer) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } - if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { + if (symbol.valueDeclaration && !areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */) { + if (node.kind !== 164 /* PropertyDeclaration */ && node.kind !== 163 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 250 /* VariableDeclaration */ || node.kind === 199 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (languageVersion < 99 /* ESNext */ && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) { - potentialWeakMapCollisions.push(node); + if (languageVersion < 99 /* ESNext */ + && (needCollisionCheckForIdentifier(node, node.name, "WeakMap") || needCollisionCheckForIdentifier(node, node.name, "WeakSet"))) { + potentialWeakMapSetCollisions.push(node); } } } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 163 /* PropertyDeclaration */ || nextDeclaration.kind === 162 /* PropertySignature */ + var message = nextDeclaration.kind === 164 /* PropertyDeclaration */ || nextDeclaration.kind === 163 /* 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); @@ -75343,8 +77353,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 160 /* Parameter */ && right.kind === 249 /* VariableDeclaration */) || - (left.kind === 249 /* VariableDeclaration */ && right.kind === 160 /* Parameter */)) { + if ((left.kind === 161 /* Parameter */ && right.kind === 250 /* VariableDeclaration */) || + (left.kind === 250 /* VariableDeclaration */ && right.kind === 161 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -75384,17 +77394,18 @@ var ts; // Grammar checking checkGrammarStatementInAmbientContext(node); var type = checkTruthinessExpression(node.expression); - checkTestingKnownTruthyCallableType(node.expression, type, node.thenStatement); + checkTestingKnownTruthyCallableOrAwaitableType(node.expression, type, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 231 /* EmptyStatement */) { + if (node.thenStatement.kind === 232 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } - function checkTestingKnownTruthyCallableType(condExpr, type, body) { - if (!strictNullChecks) { + function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, type, body) { + if (!strictNullChecks) + return; + if (getFalsyFlags(type)) return; - } var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr; var testedNode = ts.isIdentifier(location) ? location : ts.isPropertyAccessExpression(location) ? location.name @@ -75405,30 +77416,33 @@ var ts; if (!testedNode || isPropertyExpressionCast) { return; } - var possiblyFalsy = getFalsyFlags(type); - if (possiblyFalsy) { - return; - } // While it technically should be invalid for any known-truthy value - // to be tested, we de-scope to functions unrefenced in the block as a - // heuristic to identify the most common bugs. There are too many - // false positives for values sourced from type definitions without - // strictNullChecks otherwise. + // to be tested, we de-scope to functions and Promises unreferenced in + // the block as a heuristic to identify the most common bugs. There + // are too many false positives for values sourced from type + // definitions without strictNullChecks otherwise. var callSignatures = getSignaturesOfType(type, 0 /* Call */); - if (callSignatures.length === 0) { + var isPromise = !!getAwaitedTypeOfPromise(type); + if (callSignatures.length === 0 && !isPromise) { return; } var testedSymbol = getSymbolAtLocation(testedNode); if (!testedSymbol) { return; } - var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) - || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol); + var isUsed = ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol) + || body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol); if (!isUsed) { - error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + if (isPromise) { + errorAndMaybeSuggestAwait(location, + /*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type)); + } + else { + error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead); + } } } - function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) { + function isSymbolUsedInConditionBody(expr, body, testedNode, testedSymbol) { return !!ts.forEachChild(body, function check(childNode) { if (ts.isIdentifier(childNode)) { var childSymbol = getSymbolAtLocation(childNode); @@ -75465,7 +77479,7 @@ var ts; return ts.forEachChild(childNode, check); }); } - function isFunctionUsedInBinaryExpressionChain(node, testedSymbol) { + function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { @@ -75507,12 +77521,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 251 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 251 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -75546,14 +77560,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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 251 /* 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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 200 /* ArrayLiteralExpression */ || varExpr.kind === 201 /* 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. @@ -75585,7 +77599,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 === 250 /* VariableDeclarationList */) { + if (node.initializer.kind === 251 /* 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); @@ -75599,7 +77613,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 === 199 /* ArrayLiteralExpression */ || varExpr.kind === 200 /* ObjectLiteralExpression */) { + if (varExpr.kind === 200 /* ArrayLiteralExpression */ || varExpr.kind === 201 /* 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)) { @@ -75715,18 +77729,8 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); - var _a = !(use & 4 /* AllowsStringInputFlag */) || hasStringConstituent - ? downlevelIteration - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type, true] - : downlevelIteration - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] - : yieldType - ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false] - : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; + var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined; @@ -75740,6 +77744,40 @@ var ts; return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); } return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { + var _a; + if (downlevelIteration) { + return allowsStrings + ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] + : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; + } + var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + if (yieldType) { + return [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]; + } + if (isES2015OrLaterIterable((_a = inputType.symbol) === null || _a === void 0 ? void 0 : _a.escapedName)) { + return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, true]; + } + return allowsStrings + ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true] + : [ts.Diagnostics.Type_0_is_not_an_array_type, true]; + } + } + function isES2015OrLaterIterable(n) { + switch (n) { + case "Float32Array": + case "Float64Array": + case "Int16Array": + case "Int32Array": + case "Int8Array": + case "NodeList": + case "Uint16Array": + case "Uint32Array": + case "Uint8Array": + case "Uint8ClampedArray": + return true; + } + return false; } /** * Gets the requested "iteration type" from an `Iterable`-like or `AsyncIterable`-like type. @@ -75983,6 +78021,11 @@ var ts; return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType)); } } + function getPropertyNameForKnownSymbolName(symbolName) { + var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); + var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like * type from its members. @@ -75995,7 +78038,7 @@ var ts; */ function getIterationTypesOfIterableSlow(type, resolver, errorNode) { var _a; - var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); + var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); @@ -76294,12 +78337,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 168 /* SetAccessor */) { + if (func.kind === 169 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 166 /* Constructor */) { + else if (func.kind === 167 /* 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); } @@ -76317,7 +78360,7 @@ var ts; } } } - else if (func.kind !== 166 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 167 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, 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); } @@ -76346,7 +78389,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 === 285 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 286 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -76355,7 +78398,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 284 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 285 /* 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. @@ -76387,7 +78430,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 245 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 246 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -76417,10 +78460,11 @@ var ts; // Grammar checking if (catchClause.variableDeclaration) { var declaration = catchClause.variableDeclaration; - if (declaration.type) { + var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); + if (typeNode) { var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false); if (type && !(type.flags & 3 /* AnyOrUnknown */)) { - grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); + grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } else if (declaration.initializer) { @@ -76431,7 +78475,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if (blockLocal && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -76444,21 +78488,24 @@ var ts; checkBlock(node.finallyBlock); } } - function checkIndexConstraints(type) { - var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */); - var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */); + function checkIndexConstraints(type, isStatic) { + var _a, _b, _c, _d; + var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1 /* Number */); + var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0 /* String */); var stringIndexType = getIndexTypeOfType(type, 0 /* String */); var numberIndexType = getIndexTypeOfType(type, 1 /* Number */); if (stringIndexType || numberIndexType) { ts.forEach(getPropertiesOfObjectType(type), function (prop) { + if (isStatic && prop.flags & 4194304 /* Prototype */) + return; var propType = getTypeOfSymbol(prop); checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); var classDeclaration = type.symbol.valueDeclaration; - if (ts.getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(classDeclaration)) { - for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { - var member = _a[_i]; + if (ts.getObjectFlags(type) & 1 /* Class */ && classDeclaration && ts.isClassLike(classDeclaration)) { + for (var _i = 0, _e = classDeclaration.members; _i < _e.length; _i++) { + var member = _e[_i]; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. @@ -76477,7 +78524,7 @@ var ts; // condition 'errorNode === undefined' may appear if types does not declare nor string neither number indexer if (!errorNode && (ts.getObjectFlags(type) & 2 /* Interface */)) { var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0 /* String */) && getIndexTypeOfType(base, 1 /* Number */); }); - errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; + errorNode = someBaseTypeHasBothIndexers || !type.symbol.declarations ? undefined : type.symbol.declarations[0]; } } if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { // TODO: GH#18217 @@ -76501,8 +78548,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 216 /* BinaryExpression */ || - name.kind === 158 /* ComputedPropertyName */ || + (propDeclaration.kind === 217 /* BinaryExpression */ || + name.kind === 159 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -76514,7 +78561,7 @@ var ts; // check if any base class already has both property and indexer. // check should be performed only if 'type' is the first type that brings property\indexer together var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); }); - errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0]; + errorNode = someBaseClassHasBothPropertyAndIndexer || !containingType.symbol.declarations ? undefined : containingType.symbol.declarations[0]; } if (errorNode && !isTypeAssignableTo(propertyType, indexType)) { var errorMessage = indexKind === 0 /* String */ @@ -76530,6 +78577,7 @@ var ts; switch (name.escapedText) { case "any": case "unknown": + case "never": case "number": case "bigint": case "boolean": @@ -76579,7 +78627,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 173 /* TypeReference */) { + if (node.kind === 174 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -76594,14 +78642,14 @@ var ts; } /** Check that type parameter lists are identical across multiple declarations */ function checkTypeParameterListsIdentical(symbol) { - if (symbol.declarations.length === 1) { + if (symbol.declarations && symbol.declarations.length === 1) { return; } var links = getSymbolLinks(symbol); if (!links.typeParametersChecked) { links.typeParametersChecked = true; var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol); - if (declarations.length <= 1) { + if (!declarations || declarations.length <= 1) { return; } var type = getDeclaredTypeOfSymbol(symbol); @@ -76665,6 +78713,9 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassDeclaration(node) { + if (ts.some(node.decorators) && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { + grammarErrorOnNode(node.decorators[0], ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); + } if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } @@ -76693,7 +78744,8 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 8388608 /* Ambient */)) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); @@ -76753,6 +78805,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType_1); } } + checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType); var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node); if (implementedTypeNodes) { for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { @@ -76782,14 +78835,76 @@ var ts; } if (produceDiagnostics) { checkIndexConstraints(type); + checkIndexConstraints(staticType, /*isStatic*/ true); checkTypeForDuplicateIndexSignatures(node); checkPropertyInitialization(node); } } + function checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType) { + var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */); + 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 _loop_24 = function (member) { + if (ts.hasAmbientModifier(member)) { + return "continue"; + } + if (ts.isConstructorDeclaration(member)) { + ts.forEach(member.parameters, function (param) { + if (ts.isParameterPropertyDeclaration(param, member)) { + checkClassMember(param, /*memberIsParameterProperty*/ true); + } + }); + } + checkClassMember(member); + }; + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + _loop_24(member); + } + function checkClassMember(member, memberIsParameterProperty) { + var hasOverride = ts.hasOverrideModifier(member); + var hasStatic = ts.hasStaticModifier(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) { + error(member, ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); + } + else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.valueDeclaration) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { + var baseHasAbstract = ts.hasAbstractModifier(baseProp.valueDeclaration); + if (hasOverride) { + return; + } + if (!baseHasAbstract) { + 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); + } + 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); + } + } + } + else if (hasOverride) { + 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); + } + } + } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_23 = function (member) { + var _loop_25 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -76808,7 +78923,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_23(member); + _loop_25(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -76834,7 +78949,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 252 /* ClassDeclaration */ || d.kind === 253 /* InterfaceDeclaration */; + return d.kind === 253 /* ClassDeclaration */ || d.kind === 254 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -76851,6 +78966,7 @@ var ts; // but not by other kinds of members. // Base class instance member variables and accessors can be overridden by // derived class instance member variables and accessors, but not by other kinds of members. + var _a, _b; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { @@ -76879,8 +78995,8 @@ var ts; // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) - for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) { - var otherBaseType = _b[_a]; + for (var _c = 0, _d = getBaseTypes(type); _c < _d.length; _c++) { + var otherBaseType = _d[_c]; if (otherBaseType === baseType) continue; var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName); @@ -76889,7 +79005,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 221 /* ClassExpression */) { + if (derivedClassDecl.kind === 222 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -76910,7 +79026,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 === 253 /* InterfaceDeclaration */ + || base.valueDeclaration && base.valueDeclaration.parent.kind === 254 /* 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 @@ -76924,13 +79040,13 @@ var ts; ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } - else if (compilerOptions.useDefineForClassFields) { - var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 /* PropertyDeclaration */ && !d.initializer; }); + else if (useDefineForClassFields) { + var uninitialized = (_a = derived.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 164 /* PropertyDeclaration */ && !d.initializer; }); if (uninitialized && !(derived.flags & 33554432 /* Transient */) && !(baseDeclarationFlags & 128 /* Abstract */) && !(derivedDeclarationFlags & 128 /* Abstract */) - && !derived.declarations.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); })) { + && !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 8388608 /* Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -77041,7 +79157,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 163 /* PropertyDeclaration */ && + return node.kind === 164 /* PropertyDeclaration */ && !ts.hasSyntacticModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -77065,7 +79181,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 254 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -77184,7 +79300,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -77194,7 +79310,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -77223,7 +79339,7 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return evaluate(expr.expression); case 78 /* Identifier */: var identifier = expr; @@ -77231,14 +79347,14 @@ var ts; return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 202 /* ElementAccessExpression */: - case 201 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: + case 202 /* 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 === 201 /* PropertyAccessExpression */) { + if (ex.kind === 202 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -77256,7 +79372,7 @@ var ts; if (memberSymbol) { var declaration = memberSymbol.valueDeclaration; if (declaration !== member) { - if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) { + if (declaration && isBlockScopedNameDeclaredBeforeUse(declaration, member)) { return getEnumMemberValue(declaration); } error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); @@ -77271,8 +79387,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 78 /* Identifier */ || - node.kind === 201 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 202 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 202 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 203 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -77296,7 +79412,7 @@ var ts; var enumSymbol = getSymbolOfNode(node); var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { - if (enumSymbol.declarations.length > 1) { + if (enumSymbol.declarations && enumSymbol.declarations.length > 1) { var enumIsConst_1 = ts.isEnumConst(node); // check that const is placed\omitted on all enum declarations ts.forEach(enumSymbol.declarations, function (decl) { @@ -77308,7 +79424,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 !== 255 /* EnumDeclaration */) { + if (declaration.kind !== 256 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -77334,12 +79450,14 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; - if ((declaration.kind === 252 /* ClassDeclaration */ || - (declaration.kind === 251 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 8388608 /* Ambient */)) { - return declaration; + if (declarations) { + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 253 /* ClassDeclaration */ || + (declaration.kind === 252 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { + return declaration; + } } } return undefined; @@ -77387,6 +79505,7 @@ var ts; // The following checks only apply on a non-ambient instantiated module declaration. if (symbol.flags & 512 /* ValueModule */ && !inAmbientContext + && symbol.declarations && symbol.declarations.length > 1 && isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions))) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); @@ -77400,7 +79519,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, 252 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 253 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -77449,40 +79568,41 @@ var ts; } } function checkModuleAugmentationElement(node, isGlobalAugmentation) { + var _a; switch (node.kind) { - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement - for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; + for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { + var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 267 /* ExportAssignment */: + case 268 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: + case 261 /* ImportEqualsDeclaration */: + case 262 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: + case 199 /* BindingElement */: + case 250 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { - for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { - var el = _c[_b]; + for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { + var el = _d[_c]; // mark individual names in binding pattern checkModuleAugmentationElement(el, isGlobalAugmentation); } break; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 251 /* FunctionDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 253 /* ClassDeclaration */: + case 256 /* EnumDeclaration */: + case 252 /* FunctionDeclaration */: + case 254 /* InterfaceDeclaration */: + case 257 /* ModuleDeclaration */: + case 255 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -77495,7 +79615,7 @@ var ts; var reportError = !(symbol.flags & 33554432 /* Transient */); if (!reportError) { // symbol should not originate in augmentation - reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); + reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); } } break; @@ -77505,12 +79625,12 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return node; - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: do { node = node.left; } while (node.kind !== 78 /* Identifier */); return node; - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; @@ -77530,9 +79650,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 267 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 258 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 298 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 268 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -77567,14 +79687,14 @@ var ts; (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 270 /* ExportSpecifier */ ? + var message = node.kind === 271 /* 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 === 270 /* ExportSpecifier */ + && node.kind === 271 /* ExportSpecifier */ && !node.parent.parent.isTypeOnly && !(target.flags & 111551 /* Value */) && !(node.flags & 8388608 /* Ambient */)) { @@ -77589,7 +79709,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); checkAliasSymbol(node); - if (node.kind === 265 /* ImportSpecifier */ && + if (node.kind === 266 /* ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && compilerOptions.esModuleInterop && moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { @@ -77611,7 +79731,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 264 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) { // import * as ns from "foo"; @@ -77639,7 +79759,7 @@ var ts; if (ts.hasSyntacticModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 272 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 273 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { @@ -77682,10 +79802,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 257 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 258 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 258 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; - if (node.parent.kind !== 297 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 298 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -77718,14 +79838,14 @@ var ts; } function checkGrammarExportDeclaration(node) { var _a; - var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268 /* NamedExports */; + var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 269 /* NamedExports */; if (isTypeOnlyExportStar) { grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type); } return !isTypeOnlyExportStar; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 297 /* SourceFile */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 256 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 298 /* SourceFile */ || node.parent.kind === 258 /* ModuleBlock */ || node.parent.kind === 257 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -77775,7 +79895,7 @@ var ts; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { @@ -77796,12 +79916,15 @@ var ts; } } function checkExportAssignment(node) { - if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { + var illegalContextMessage = node.isExportEquals + ? ts.Diagnostics.An_export_assignment_must_be_at_the_top_level_of_a_file_or_module_declaration + : ts.Diagnostics.A_default_export_must_be_at_the_top_level_of_a_file_or_module_declaration; + if (checkGrammarModuleElementContext(node, illegalContextMessage)) { // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 298 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 257 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -77861,7 +79984,7 @@ var ts; var exportEqualsSymbol = moduleSymbol.exports.get("export="); if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) { var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration; - if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { + if (declaration && !isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) { error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } @@ -77885,10 +80008,12 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; - if (isNotOverload(declaration)) { - diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + if (!isDuplicatedCommonJSExport(declarations)) { + for (var _i = 0, _b = declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (isNotOverload(declaration)) { + diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id))); + } } } } @@ -77897,6 +80022,11 @@ var ts; links.exportsChecked = true; } } + function isDuplicatedCommonJSExport(declarations) { + return declarations + && declarations.length > 1 + && declarations.every(function (d) { return ts.isInJSFile(d) && ts.isAccessExpression(d) && (ts.isExportsIdentifier(d.expression) || ts.isModuleExportsAccessExpression(d.expression)); }); + } function checkSourceElement(node) { if (node) { var saveCurrentNode = currentNode; @@ -77918,171 +80048,171 @@ 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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: + case 257 /* ModuleDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 252 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 232 /* FirstStatement */ && kind <= 248 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 233 /* FirstStatement */ && kind <= 249 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 159 /* TypeParameter */: + case 160 /* TypeParameter */: return checkTypeParameter(node); - case 160 /* Parameter */: + case 161 /* Parameter */: return checkParameter(node); - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: return checkPropertyDeclaration(node); - case 162 /* PropertySignature */: + case 163 /* PropertySignature */: return checkPropertySignature(node); - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 171 /* IndexSignature */: + case 176 /* ConstructorType */: + case 175 /* FunctionType */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 172 /* IndexSignature */: return checkSignatureDeclaration(node); - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: return checkMethodDeclaration(node); - case 166 /* Constructor */: + case 167 /* Constructor */: return checkConstructorDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return checkAccessorDeclaration(node); - case 173 /* TypeReference */: + case 174 /* TypeReference */: return checkTypeReferenceNode(node); - case 172 /* TypePredicate */: + case 173 /* TypePredicate */: return checkTypePredicate(node); - case 176 /* TypeQuery */: + case 177 /* TypeQuery */: return checkTypeQuery(node); - case 177 /* TypeLiteral */: + case 178 /* TypeLiteral */: return checkTypeLiteral(node); - case 178 /* ArrayType */: + case 179 /* ArrayType */: return checkArrayType(node); - case 179 /* TupleType */: + case 180 /* TupleType */: return checkTupleType(node); - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 183 /* UnionType */: + case 184 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 186 /* ParenthesizedType */: - case 180 /* OptionalType */: - case 181 /* RestType */: + case 187 /* ParenthesizedType */: + case 181 /* OptionalType */: + case 182 /* RestType */: return checkSourceElement(node.type); - case 187 /* ThisType */: + case 188 /* ThisType */: return checkThisType(node); - case 188 /* TypeOperator */: + case 189 /* TypeOperator */: return checkTypeOperator(node); - case 184 /* ConditionalType */: + case 185 /* ConditionalType */: return checkConditionalType(node); - case 185 /* InferType */: + case 186 /* InferType */: return checkInferType(node); - case 193 /* TemplateLiteralType */: + case 194 /* TemplateLiteralType */: return checkTemplateLiteralType(node); - case 195 /* ImportType */: + case 196 /* ImportType */: return checkImportType(node); - case 192 /* NamedTupleMember */: + case 193 /* NamedTupleMember */: return checkNamedTupleMember(node); - case 315 /* JSDocAugmentsTag */: + case 318 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 316 /* JSDocImplementsTag */: + case 319 /* JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 335 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: + case 329 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 330 /* JSDocTemplateTag */: + case 334 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 329 /* JSDocTypeTag */: + case 333 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 326 /* JSDocParameterTag */: + case 330 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 333 /* JSDocPropertyTag */: + case 337 /* JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 308 /* JSDocFunctionType */: + case 309 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 306 /* JSDocNonNullableType */: - case 305 /* JSDocNullableType */: - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 312 /* JSDocTypeLiteral */: + case 307 /* JSDocNonNullableType */: + case 306 /* JSDocNullableType */: + case 304 /* JSDocAllType */: + case 305 /* JSDocUnknownType */: + case 314 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 309 /* JSDocVariadicType */: + case 310 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 301 /* JSDocTypeExpression */: + case 302 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 189 /* IndexedAccessType */: + case 190 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 190 /* MappedType */: + case 191 /* MappedType */: return checkMappedType(node); - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 230 /* Block */: - case 257 /* ModuleBlock */: + case 231 /* Block */: + case 258 /* ModuleBlock */: return checkBlock(node); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return checkVariableStatement(node); - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: return checkExpressionStatement(node); - case 234 /* IfStatement */: + case 235 /* IfStatement */: return checkIfStatement(node); - case 235 /* DoStatement */: + case 236 /* DoStatement */: return checkDoStatement(node); - case 236 /* WhileStatement */: + case 237 /* WhileStatement */: return checkWhileStatement(node); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return checkForStatement(node); - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: return checkForInStatement(node); - case 239 /* ForOfStatement */: + case 240 /* ForOfStatement */: return checkForOfStatement(node); - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: + case 241 /* ContinueStatement */: + case 242 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: return checkReturnStatement(node); - case 243 /* WithStatement */: + case 244 /* WithStatement */: return checkWithStatement(node); - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: return checkSwitchStatement(node); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return checkLabeledStatement(node); - case 246 /* ThrowStatement */: + case 247 /* ThrowStatement */: return checkThrowStatement(node); - case 247 /* TryStatement */: + case 248 /* TryStatement */: return checkTryStatement(node); - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 198 /* BindingElement */: + case 199 /* BindingElement */: return checkBindingElement(node); - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: return checkClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 254 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 255 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: return checkImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: return checkExportDeclaration(node); - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return checkExportAssignment(node); - case 231 /* EmptyStatement */: - case 248 /* DebuggerStatement */: + case 232 /* EmptyStatement */: + case 249 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 271 /* MissingDeclaration */: + case 272 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -78127,7 +80257,8 @@ var ts; if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) { // Else we will add a diagnostic, see `checkJSDocVariadicType`. var host_1 = ts.getHostSignatureFromJSDoc(paramTag); - if (host_1) { + var isCallbackTag = ts.isJSDocCallbackTag(paramTag.parent.parent); + if (host_1 || isCallbackTag) { /* Only return an array type if the corresponding parameter is marked as a rest parameter, or if there are no parameters. So in the following situation we will not create an array type: @@ -78135,7 +80266,9 @@ var ts; function f(a) {} Because `a` will just be of type `number | undefined`. A synthetic `...args` will also be added, which *will* get an array type. */ - var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters); + var lastParamDeclaration = isCallbackTag + ? ts.lastOrUndefined(paramTag.parent.parent.typeExpression.parameters) + : ts.lastOrUndefined(host_1.parameters); var symbol = ts.getParameterSymbolFromJSDoc(paramTag); if (!lastParamDeclaration || symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) { @@ -78178,33 +80311,33 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 205 /* TaggedTemplateExpression */: - case 161 /* Decorator */: - case 275 /* JsxOpeningElement */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: + case 206 /* TaggedTemplateExpression */: + case 162 /* Decorator */: + case 276 /* 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 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 221 /* ClassExpression */: + case 222 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 274 /* JsxSelfClosingElement */: + case 275 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 273 /* JsxElement */: + case 274 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -78246,7 +80379,7 @@ var ts; checkGrammarSourceFile(node); ts.clear(potentialThisCollisions); ts.clear(potentialNewTargetCollisions); - ts.clear(potentialWeakMapCollisions); + ts.clear(potentialWeakMapSetCollisions); ts.forEach(node.statements, checkSourceElement); checkSourceElement(node.endOfFileToken); checkDeferredNodes(node); @@ -78276,9 +80409,9 @@ var ts; ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope); ts.clear(potentialNewTargetCollisions); } - if (potentialWeakMapCollisions.length) { - ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision); - ts.clear(potentialWeakMapCollisions); + if (potentialWeakMapSetCollisions.length) { + ts.forEach(potentialWeakMapSetCollisions, checkWeakMapSetCollision); + ts.clear(potentialWeakMapSetCollisions); } links.flags |= 1 /* TypeChecked */; } @@ -78350,17 +80483,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 297 /* SourceFile */: - if (!ts.isExternalOrCommonJsModule(location)) + case 298 /* SourceFile */: + if (!ts.isExternalModule(location)) break; // falls through - case 256 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 257 /* ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 221 /* ClassExpression */: + case 222 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -78368,8 +80501,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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* 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. @@ -78378,7 +80511,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 208 /* FunctionExpression */: + case 209 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -78418,6 +80551,16 @@ var ts; }); } } + function copyLocallyVisibleExportSymbols(source, meaning) { + if (meaning) { + source.forEach(function (symbol) { + // Similar condition as in `resolveNameHelper` + if (!ts.getDeclarationOfKind(symbol, 271 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 270 /* NamespaceExport */)) { + copySymbol(symbol, meaning); + } + }); + } + } } function isTypeDeclarationName(name) { return name.kind === 78 /* Identifier */ && @@ -78426,19 +80569,19 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 159 /* TypeParameter */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 325 /* JSDocEnumTag */: + case 160 /* TypeParameter */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 256 /* EnumDeclaration */: + case 335 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: + case 329 /* JSDocEnumTag */: return true; - case 262 /* ImportClause */: + case 263 /* ImportClause */: return node.isTypeOnly; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 266 /* ImportSpecifier */: + case 271 /* ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -78446,25 +80589,25 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 158 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 173 /* TypeReference */; + return node.parent.kind === 174 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 201 /* PropertyAccessExpression */) { + while (node.parent.kind === 202 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 223 /* ExpressionWithTypeArguments */; + return node.parent.kind === 224 /* ExpressionWithTypeArguments */; } - function isJSDocEntryNameReference(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + function getJSDocEntryNameReference(node) { + while (node.parent.kind === 158 /* QualifiedName */) { node = node.parent; } - while (node.parent.kind === 201 /* PropertyAccessExpression */) { + while (node.parent.kind === 202 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 302 /* JSDocNameReference */; + return ts.isJSDocNameReference(node.parent) ? node.parent : undefined; } function forEachEnclosingClass(node, callback) { var result; @@ -78492,13 +80635,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 157 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 158 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 260 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 261 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 266 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 267 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -78524,7 +80667,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 195 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 196 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -78534,7 +80677,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 201 /* PropertyAccessExpression */ && + name.parent.kind === 202 /* PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name)) { @@ -78544,7 +80687,7 @@ var ts; } } } - if (name.parent.kind === 266 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 267 /* 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); @@ -78554,7 +80697,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 260 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 261 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -78572,7 +80715,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 === 223 /* ExpressionWithTypeArguments */) { + if (name.parent.kind === 224 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { @@ -78588,10 +80731,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 326 /* JSDocParameterTag */) { + if (name.parent.kind === 330 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 159 /* TypeParameter */ && name.parent.parent.kind === 330 /* JSDocTemplateTag */) { + if (name.parent.kind === 160 /* TypeParameter */ && name.parent.parent.kind === 334 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -78608,36 +80751,56 @@ var ts; } return resolveEntityName(name, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (name.kind === 201 /* PropertyAccessExpression */ || name.kind === 157 /* QualifiedName */) { + else if (name.kind === 202 /* PropertyAccessExpression */ || name.kind === 158 /* QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 201 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name); + if (name.kind === 202 /* PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* Normal */); } else { - checkQualifiedName(name); + checkQualifiedName(name, 0 /* Normal */); } return links.resolvedSymbol; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 173 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 174 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (isJSDocEntryNameReference(name)) { + var jsdocReference = getJSDocEntryNameReference(name); + if (jsdocReference || ts.isJSDocLink(name.parent)) { var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; - return resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); + var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ false, ts.getHostSignatureFromJSDoc(name)); + if (symbol) { + return symbol; + } + else if (ts.isQualifiedName(name) && ts.isIdentifier(name.left)) { + // resolve C.m as a static member first + var links = getNodeLinks(name); + if (links.resolvedSymbol) { + return links.resolvedSymbol; + } + checkQualifiedName(name, 0 /* Normal */); + if (links.resolvedSymbol) { + return links.resolvedSymbol; + } + // then resolve it as an instance member + var s = resolveEntityName(name.left, meaning, /*ignoreErrors*/ false); + if (s) { + var t = getDeclaredTypeOfSymbol(s); + return getPropertyOfType(t, name.right.escapedText); + } + } } - if (name.parent.kind === 172 /* TypePredicate */) { + if (name.parent.kind === 173 /* TypePredicate */) { return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); } - // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 298 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; @@ -78660,8 +80823,8 @@ var ts; if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 198 /* BindingElement */ && - grandParent.kind === 196 /* ObjectBindingPattern */ && + else if (parent.kind === 199 /* BindingElement */ && + grandParent.kind === 197 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -78673,8 +80836,8 @@ var ts; switch (node.kind) { case 78 /* Identifier */: case 79 /* PrivateIdentifier */: - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 202 /* PropertyAccessExpression */: + case 158 /* QualifiedName */: return getSymbolOfNameOrPropertyAccessExpression(node); case 107 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -78688,14 +80851,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 187 /* ThisType */: + case 188 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 105 /* SuperKeyword */: return checkExpression(node).symbol; case 132 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 166 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 167 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -78706,7 +80869,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 === 261 /* ImportDeclaration */ || node.parent.kind === 267 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 262 /* ImportDeclaration */ || node.parent.kind === 268 /* 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); @@ -78728,7 +80891,7 @@ var ts; case 38 /* EqualsGreaterThanToken */: case 83 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 195 /* ImportType */: + case 196 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; case 92 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; @@ -78737,7 +80900,7 @@ var ts; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 289 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 290 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -78816,27 +80979,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 200 /* ObjectLiteralExpression */ || expr.kind === 199 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 201 /* ObjectLiteralExpression */ || expr.kind === 200 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 239 /* ForOfStatement */) { + if (expr.parent.kind === 240 /* 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 === 216 /* BinaryExpression */) { + if (expr.parent.kind === 217 /* 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 === 288 /* PropertyAssignment */) { - var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType; - var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 289 /* 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); + return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -78880,7 +81043,7 @@ var ts; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: @@ -78977,6 +81140,7 @@ var ts; // When resolved as an expression identifier, if the given node references an exported entity, return the declaration // node of the exported entity's container. Otherwise, return undefined. function getReferencedExportContainer(nodeIn, prefixLocals) { + var _a; var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { // When resolving the export container for the name of a module or enum @@ -78997,7 +81161,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 297 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 298 /* 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. @@ -79027,11 +81191,12 @@ var ts; return undefined; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { - return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287 /* CatchClause */; + return symbol.valueDeclaration + && ts.isBindingElement(symbol.valueDeclaration) + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 288 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -79059,7 +81224,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 === 230 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 231 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -79100,19 +81265,19 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 263 /* ImportClause */: + case 264 /* NamespaceImport */: + case 266 /* ImportSpecifier */: + case 271 /* ExportSpecifier */: var symbol = getSymbolOfNode(node) || unknownSymbol; return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return node.expression && node.expression.kind === 78 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; @@ -79121,7 +81286,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 297 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 298 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -79188,13 +81353,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 92 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameter(parameter) { return !!strictNullChecks && @@ -79229,15 +81394,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 291 /* EnumMember */: - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 292 /* EnumMember */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 291 /* EnumMember */) { + if (node.kind === 292 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -79509,12 +81674,12 @@ var ts; getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 168 /* SetAccessor */ ? 167 /* GetAccessor */ : 168 /* SetAccessor */; + var otherKind = accessor.kind === 169 /* SetAccessor */ ? 168 /* GetAccessor */ : 169 /* 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 === 168 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 167 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 169 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 168 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -79530,7 +81695,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 297 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 298 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -79553,11 +81718,13 @@ var ts; var s = _a[_i]; if (s.mergeId) { var merged = getMergedSymbol(s); - for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { - var d = _c[_b]; - var declFile = ts.getSourceFileOfNode(d); - if (declFile === importTarget) { - return true; + if (merged.declarations) { + for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declFile = ts.getSourceFileOfNode(d); + if (declFile === importTarget) { + return true; + } } } } @@ -79565,7 +81732,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 223 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 286 /* HeritageClause */; + return node.parent && node.parent.kind === 224 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 287 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -79577,7 +81744,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 78 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 201 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 78 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 202 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -79586,10 +81753,7 @@ var ts; // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForSymbol(symbol, meaning) { // program does not have any files with type reference directives - bail out - if (!fileToDirective) { - return undefined; - } - if (!isSymbolFromTypeDeclarationFile(symbol)) { + if (!fileToDirective || !isSymbolFromTypeDeclarationFile(symbol)) { return undefined; } // check what declarations in the symbol can contribute to the target meaning @@ -79628,7 +81792,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 297 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 298 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -79656,12 +81820,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 256 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 257 /* 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, 297 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 298 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -79681,7 +81845,7 @@ var ts; // It is an error for a non-external-module (i.e. script) to declare its own `globalThis`. // We can't use `builtinGlobals` for this due to synthetic expando-namespace generation in JS files. var fileGlobalThisSymbol = file.locals.get("globalThis"); - if (fileGlobalThisSymbol) { + if (fileGlobalThisSymbol === null || fileGlobalThisSymbol === void 0 ? void 0 : fileGlobalThisSymbol.declarations) { for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) { var declaration = _e[_d]; diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis")); @@ -79805,6 +81969,16 @@ var ts; if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } + else if (helper & 524288 /* ClassPrivateFieldGet */) { + if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); + } + } + else if (helper & 1048576 /* ClassPrivateFieldSet */) { + if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); + } + } } } } @@ -79854,14 +82028,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 165 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 166 /* 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 === 167 /* GetAccessor */ || node.kind === 168 /* SetAccessor */) { + else if (node.kind === 168 /* GetAccessor */ || node.kind === 169 /* 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); @@ -79874,24 +82048,41 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly, lastOverride; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 142 /* ReadonlyKeyword */) { - if (node.kind === 162 /* PropertySignature */ || node.kind === 164 /* MethodSignature */) { + if (node.kind === 163 /* PropertySignature */ || node.kind === 165 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 171 /* IndexSignature */) { + if (node.kind === 172 /* IndexSignature */ && (modifier.kind !== 123 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 84 /* ConstKeyword */: - if (node.kind !== 255 /* EnumDeclaration */) { + if (node.kind !== 256 /* EnumDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84 /* ConstKeyword */)); } break; + case 156 /* 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"); + } + else if (flags & 2 /* Ambient */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); + } + else if (flags & 64 /* Readonly */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); + } + else if (flags & 256 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); + } + flags |= 16384 /* Override */; + lastOverride = modifier; + break; case 122 /* PublicKeyword */: case 121 /* ProtectedKeyword */: case 120 /* PrivateKeyword */: @@ -79899,6 +82090,9 @@ var ts; if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); + } else if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } @@ -79908,7 +82102,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 === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 258 /* ModuleBlock */ || node.parent.kind === 298 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -79919,7 +82113,7 @@ var ts; return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); } } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier); } flags |= ts.modifierToFlag(modifier.kind); @@ -79934,17 +82128,17 @@ 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 === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + else if (node.parent.kind === 258 /* ModuleBlock */ || node.parent.kind === 298 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 160 /* Parameter */) { + else if (node.kind === 161 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { - return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static"); + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } flags |= 32 /* Static */; lastStatic = modifier; @@ -79953,8 +82147,8 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 163 /* PropertyDeclaration */ && node.kind !== 162 /* PropertySignature */ && node.kind !== 171 /* IndexSignature */ && node.kind !== 160 /* Parameter */) { - // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. + else if (node.kind !== 164 /* PropertyDeclaration */ && node.kind !== 163 /* PropertySignature */ && node.kind !== 172 /* IndexSignature */ && node.kind !== 161 /* Parameter */) { + // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; @@ -79976,14 +82170,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 === 160 /* Parameter */) { + else if (node.kind === 161 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 87 /* DefaultKeyword */: - var container = node.parent.kind === 297 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 256 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 298 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 257 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -79995,16 +82189,19 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } + else if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); + } 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 === 160 /* Parameter */) { + else if (node.kind === 161 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 257 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 258 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - else if (ts.isPrivateIdentifierPropertyDeclaration(node)) { + else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } flags |= 2 /* Ambient */; @@ -80014,15 +82211,15 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 252 /* ClassDeclaration */ && - node.kind !== 175 /* ConstructorType */) { - if (node.kind !== 165 /* MethodDeclaration */ && - node.kind !== 163 /* PropertyDeclaration */ && - node.kind !== 167 /* GetAccessor */ && - node.kind !== 168 /* SetAccessor */) { + if (node.kind !== 253 /* ClassDeclaration */ && + node.kind !== 176 /* ConstructorType */) { + if (node.kind !== 166 /* MethodDeclaration */ && + node.kind !== 164 /* PropertyDeclaration */ && + node.kind !== 168 /* GetAccessor */ && + node.kind !== 169 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 252 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 253 /* 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 */) { @@ -80034,6 +82231,9 @@ var ts; if (flags & 256 /* Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); + } } if (ts.isNamedDeclaration(node) && node.name.kind === 79 /* PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); @@ -80047,7 +82247,7 @@ var ts; 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 === 160 /* Parameter */) { + else if (node.kind === 161 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } if (flags & 128 /* Abstract */) { @@ -80058,13 +82258,16 @@ var ts; break; } } - if (node.kind === 166 /* Constructor */) { + if (node.kind === 167 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217 } + if (flags & 16384 /* Override */) { + return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 + } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } @@ -80073,13 +82276,13 @@ var ts; } return false; } - else if ((node.kind === 261 /* ImportDeclaration */ || node.kind === 260 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 262 /* ImportDeclaration */ || node.kind === 261 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 161 /* 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 === 160 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 161 /* 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 */) { @@ -80100,38 +82303,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 171 /* IndexSignature */: - case 256 /* ModuleDeclaration */: - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 160 /* Parameter */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 167 /* Constructor */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 172 /* IndexSignature */: + case 257 /* ModuleDeclaration */: + case 262 /* ImportDeclaration */: + case 261 /* ImportEqualsDeclaration */: + case 268 /* ExportDeclaration */: + case 267 /* ExportAssignment */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 161 /* Parameter */: return false; default: - if (node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 258 /* ModuleBlock */ || node.parent.kind === 298 /* SourceFile */) { return false; } switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 129 /* AsyncKeyword */); - case 252 /* ClassDeclaration */: - case 175 /* ConstructorType */: + case 253 /* ClassDeclaration */: + case 176 /* ConstructorType */: return nodeHasAnyModifiersExcept(node, 125 /* AbstractKeyword */); - case 253 /* InterfaceDeclaration */: - case 232 /* VariableStatement */: - case 254 /* TypeAliasDeclaration */: + case 254 /* InterfaceDeclaration */: + case 233 /* VariableStatement */: + case 255 /* TypeAliasDeclaration */: return true; - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 84 /* ConstKeyword */); default: ts.Debug.fail(); @@ -80143,10 +82346,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 166 /* MethodDeclaration */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -80307,7 +82510,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 === 222 /* OmittedExpression */) { + if (arg.kind === 223 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -80384,20 +82587,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 158 /* ComputedPropertyName */) { + if (node.kind !== 159 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 216 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 217 /* 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 === 251 /* FunctionDeclaration */ || - node.kind === 208 /* FunctionExpression */ || - node.kind === 165 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 252 /* FunctionDeclaration */ || + node.kind === 209 /* FunctionExpression */ || + node.kind === 166 /* MethodDeclaration */); if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -80416,7 +82619,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 === 290 /* SpreadAssignment */) { + if (prop.kind === 291 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -80427,24 +82630,24 @@ var ts; continue; } var name = prop.name; - if (name.kind === 158 /* ComputedPropertyName */) { + if (name.kind === 159 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 289 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 290 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } if (name.kind === 79 /* PrivateIdentifier */) { - return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); + grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 129 /* AsyncKeyword */ || prop.kind !== 165 /* MethodDeclaration */) { + if (mod.kind !== 129 /* AsyncKeyword */ || prop.kind !== 166 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -80459,10 +82662,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 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -80470,13 +82673,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 167 /* GetAccessor */: + case 168 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 168 /* SetAccessor */: + case 169 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -80511,11 +82714,12 @@ var ts; } } function checkGrammarJsxElement(node) { + checkGrammarJsxName(node.tagName); checkGrammarTypeArguments(node, node.typeArguments); var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 282 /* JsxSpreadAttribute */) { + if (attr.kind === 283 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -80525,11 +82729,32 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 283 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 284 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } } + function checkGrammarJsxName(node) { + if (ts.isPropertyAccessExpression(node)) { + var propName = node; + do { + var check_1 = checkGrammarJsxNestedIdentifier(propName.name); + if (check_1) { + return check_1; + } + propName = propName.expression; + } while (ts.isPropertyAccessExpression(propName)); + var check = checkGrammarJsxNestedIdentifier(propName); + if (check) { + return check; + } + } + function checkGrammarJsxNestedIdentifier(name) { + if (ts.isIdentifier(name) && ts.idText(name).indexOf(":") !== -1) { + return grammarErrorOnNode(name, ts.Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names); + } + } + } function checkGrammarJsxExpression(node) { if (node.expression && ts.isCommaSequence(node.expression)) { return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array); @@ -80539,7 +82764,7 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 239 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 240 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { @@ -80557,7 +82782,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 !== 166 /* Constructor */) { + if (func && func.kind !== 167 /* 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); @@ -80569,7 +82794,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 250 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 251 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -80584,20 +82809,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 239 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 239 /* 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 === 238 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 239 /* 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); @@ -80607,26 +82832,34 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 8388608 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */) && (accessor.parent.kind !== 178 /* TypeLiteral */) && (accessor.parent.kind !== 254 /* InterfaceDeclaration */)) { if (languageVersion < 1 /* ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } + if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); + } if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } - if (accessor.body && ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { - return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + if (accessor.body) { + if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); + } + if (accessor.parent.kind === 178 /* TypeLiteral */ || accessor.parent.kind === 254 /* InterfaceDeclaration */) { + return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); + } } if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 167 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 168 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 168 /* SetAccessor */) { + if (accessor.kind === 169 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -80648,10 +82881,10 @@ 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 === 167 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 168 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 167 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 168 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -80669,7 +82902,7 @@ var ts; } } switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 78 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -80681,13 +82914,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: if (!ts.hasSyntacticModifier(parent, 32 /* Static */) || !ts.hasEffectiveModifier(parent, 64 /* Readonly */)) { 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 162 /* PropertySignature */: + case 163 /* 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); } @@ -80697,7 +82930,7 @@ var ts; } } else if (node.operator === 142 /* ReadonlyKeyword */) { - if (node.type.kind !== 178 /* ArrayType */ && node.type.kind !== 179 /* TupleType */) { + if (node.type.kind !== 179 /* ArrayType */ && node.type.kind !== 180 /* TupleType */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148 /* SymbolKeyword */)); } } @@ -80711,8 +82944,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 165 /* MethodDeclaration */) { - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 166 /* MethodDeclaration */) { + if (node.parent.kind === 201 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 129 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -80732,6 +82965,9 @@ var ts; } } if (ts.isClassLike(node.parent)) { + if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); + } // Technically, computed properties in ambient contexts is disallowed // for property declarations and accessors too, not just methods. // However, property declarations disallow computed names in general, @@ -80740,14 +82976,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 === 165 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 166 /* 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 === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 254 /* 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 === 177 /* TypeLiteral */) { + else if (node.parent.kind === 178 /* 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); } } @@ -80758,11 +82994,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 245 /* LabeledStatement */: + case 246 /* 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 === 240 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 241 /* 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); @@ -80770,8 +83006,8 @@ var ts; return false; } break; - case 244 /* SwitchStatement */: - if (node.kind === 241 /* BreakStatement */ && !node.label) { + case 245 /* SwitchStatement */: + if (node.kind === 242 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -80786,13 +83022,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 241 /* BreakStatement */ + var message = node.kind === 242 /* 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 === 241 /* BreakStatement */ + var message = node.kind === 242 /* 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); @@ -80816,12 +83052,12 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 215 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 214 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && + expr.kind === 215 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -80852,7 +83088,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 238 /* ForInStatement */ && node.parent.parent.kind !== 239 /* ForOfStatement */) { + if (node.parent.parent.kind !== 239 /* ForInStatement */ && node.parent.parent.kind !== 240 /* ForOfStatement */) { if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } @@ -80865,7 +83101,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 232 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 233 /* 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 @@ -80933,15 +83169,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 234 /* IfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 235 /* IfStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: + case 244 /* WithStatement */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: return false; - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -81026,14 +83262,14 @@ var ts; if (ts.isStringLiteral(node.name) && node.name.text === "constructor") { return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor); } - if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { + if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 253 /* InterfaceDeclaration */) { + else if (node.parent.kind === 254 /* 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; } @@ -81041,7 +83277,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 177 /* TypeLiteral */) { + else if (node.parent.kind === 178 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -81075,13 +83311,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 253 /* InterfaceDeclaration */ || - node.kind === 254 /* TypeAliasDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 260 /* ImportEqualsDeclaration */ || - node.kind === 267 /* ExportDeclaration */ || - node.kind === 266 /* ExportAssignment */ || - node.kind === 259 /* NamespaceExportDeclaration */ || + if (node.kind === 254 /* InterfaceDeclaration */ || + node.kind === 255 /* TypeAliasDeclaration */ || + node.kind === 262 /* ImportDeclaration */ || + node.kind === 261 /* ImportEqualsDeclaration */ || + node.kind === 268 /* ExportDeclaration */ || + node.kind === 267 /* ExportAssignment */ || + node.kind === 260 /* NamespaceExportDeclaration */ || ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -81090,7 +83326,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 === 232 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 233 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -81113,7 +83349,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 === 230 /* Block */ || node.parent.kind === 257 /* ModuleBlock */ || node.parent.kind === 297 /* SourceFile */) { + if (node.parent.kind === 231 /* Block */ || node.parent.kind === 258 /* ModuleBlock */ || node.parent.kind === 298 /* SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -81135,10 +83371,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, 191 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 192 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 291 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 292 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -81244,7 +83480,7 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && forEachType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } @@ -81296,6 +83532,10 @@ var ts; // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + var match = getMatchingUnionConstituentForType(target, source); + if (match) { + return match; + } var sourceProperties = getPropertiesOfType(source); if (sourceProperties) { var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); @@ -81313,33 +83553,19 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 251 /* FunctionDeclaration */ && declaration.kind !== 165 /* MethodDeclaration */) || + return (declaration.kind !== 252 /* FunctionDeclaration */ && declaration.kind !== 166 /* 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 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: + case 266 /* ImportSpecifier */: + case 271 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); } } - function isSomeImportDeclaration(decl) { - switch (decl.kind) { - case 262 /* ImportClause */: // For default import - case 260 /* ImportEqualsDeclaration */: - case 263 /* NamespaceImport */: - case 265 /* ImportSpecifier */: // For rename import `x as y` - return true; - case 78 /* Identifier */: - // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 265 /* ImportSpecifier */; - default: - return false; - } - } var JsxNames; (function (JsxNames) { JsxNames.JSX = "JSX"; @@ -81370,7 +83596,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; @@ -81559,6 +83784,24 @@ var ts; return updated; } ts.visitFunctionBody = visitFunctionBody; + /** + * Visits an iteration body, adding any block-scoped variables required by the transformation. + */ + function visitIterationBody(body, visitor, context) { + context.startBlockScope(); + var updated = visitNode(body, visitor, ts.isStatement, context.factory.liftToBlock); + var declarations = context.endBlockScope(); + if (ts.some(declarations)) { + if (ts.isBlock(updated)) { + declarations.push.apply(declarations, updated.statements); + return context.factory.updateBlock(updated, declarations); + } + declarations.push(updated); + return context.factory.createBlock(declarations); + } + return updated; + } + ts.visitIterationBody = visitIterationBody; function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor, nodeVisitor) { if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (nodeVisitor === void 0) { nodeVisitor = visitNode; } @@ -81567,299 +83810,433 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 156 /* LastToken */) || kind === 187 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 157 /* LastToken */) || kind === 188 /* ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names case 78 /* Identifier */: - return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 157 /* QualifiedName */: + ts.Debug.type(node); + return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); + case 158 /* QualifiedName */: + ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: + ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 159 /* TypeParameter */: + case 160 /* 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 160 /* Parameter */: - return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 161 /* Decorator */: + case 161 /* Parameter */: + ts.Debug.type(node); + return factory.updateParameterDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 162 /* Decorator */: + ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 162 /* PropertySignature */: - return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 163 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + ts.Debug.type(node); + return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 164 /* PropertyDeclaration */: + 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.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 164 /* MethodSignature */: - return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 165 /* MethodDeclaration */: - return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), 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 166 /* Constructor */: + nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 165 /* MethodSignature */: + ts.Debug.type(node); + return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 166 /* MethodDeclaration */: + ts.Debug.type(node); + return factory.updateMethodDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + case 167 /* Constructor */: + 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 167 /* GetAccessor */: + case 168 /* 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 168 /* SetAccessor */: + case 169 /* 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 169 /* CallSignature */: + case 170 /* 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 170 /* ConstructSignature */: + case 171 /* 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 171 /* IndexSignature */: + case 172 /* 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 172 /* TypePredicate */: - return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 173 /* TypeReference */: + case 173 /* TypePredicate */: + ts.Debug.type(node); + return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 174 /* TypeReference */: + ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 174 /* FunctionType */: + case 175 /* 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 175 /* ConstructorType */: + case 176 /* 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 176 /* TypeQuery */: + case 177 /* TypeQuery */: + ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName)); - case 177 /* TypeLiteral */: + case 178 /* TypeLiteral */: + ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 178 /* ArrayType */: + case 179 /* ArrayType */: + ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 179 /* TupleType */: + case 180 /* TupleType */: + ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 180 /* OptionalType */: + case 181 /* OptionalType */: + ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* RestType */: + case 182 /* RestType */: + ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 182 /* UnionType */: + case 183 /* UnionType */: + ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 183 /* IntersectionType */: + case 184 /* IntersectionType */: + ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 184 /* ConditionalType */: + case 185 /* 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 185 /* InferType */: + case 186 /* InferType */: + ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 195 /* ImportType */: + case 196 /* 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 192 /* NamedTupleMember */: - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 186 /* ParenthesizedType */: + case 193 /* NamedTupleMember */: + ts.Debug.type(node); + return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); + case 187 /* ParenthesizedType */: + ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 188 /* TypeOperator */: + case 189 /* TypeOperator */: + ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 189 /* IndexedAccessType */: + case 190 /* IndexedAccessType */: + ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 190 /* MappedType */: - return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 191 /* LiteralType */: + case 191 /* MappedType */: + ts.Debug.type(node); + return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 192 /* LiteralType */: + ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 193 /* TemplateLiteralType */: + case 194 /* TemplateLiteralType */: + ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 194 /* TemplateLiteralTypeSpan */: + case 195 /* TemplateLiteralTypeSpan */: + ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 197 /* ObjectBindingPattern */: + ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 197 /* ArrayBindingPattern */: + case 198 /* ArrayBindingPattern */: + ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 198 /* BindingElement */: - return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 199 /* 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 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: + ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: + ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier)); + 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)); } - return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier)); - case 202 /* ElementAccessExpression */: + ts.Debug.type(node); + return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); + case 203 /* ElementAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); + 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 203 /* CallExpression */: + case 204 /* CallExpression */: if (node.flags & 32 /* OptionalChain */) { - return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + 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 204 /* NewExpression */: + case 205 /* 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 205 /* TaggedTemplateExpression */: - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 206 /* TypeAssertionExpression */: + case 206 /* TaggedTemplateExpression */: + ts.Debug.type(node); + return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); + case 207 /* TypeAssertionExpression */: + ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: + ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 208 /* FunctionExpression */: - return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 209 /* ArrowFunction */: - 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.isToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 210 /* DeleteExpression */: + case 209 /* FunctionExpression */: + ts.Debug.type(node); + return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + case 210 /* ArrowFunction */: + ts.Debug.type(node); + return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + case 211 /* DeleteExpression */: + ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 211 /* TypeOfExpression */: + case 212 /* TypeOfExpression */: + ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* VoidExpression */: + case 213 /* VoidExpression */: + ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* AwaitExpression */: + case 214 /* AwaitExpression */: + ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: + ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: + ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 216 /* BinaryExpression */: - return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 217 /* ConditionalExpression */: - return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 218 /* TemplateExpression */: + case 217 /* BinaryExpression */: + ts.Debug.type(node); + return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); + case 218 /* ConditionalExpression */: + ts.Debug.type(node); + return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); + case 219 /* TemplateExpression */: + ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 219 /* YieldExpression */: - return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 220 /* SpreadElement */: + case 220 /* YieldExpression */: + ts.Debug.type(node); + return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 221 /* SpreadElement */: + ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 221 /* ClassExpression */: + case 222 /* 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 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: + ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 224 /* AsExpression */: + case 225 /* AsExpression */: + ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 225 /* NonNullExpression */: + case 226 /* 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 226 /* MetaProperty */: + case 227 /* MetaProperty */: + ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 228 /* TemplateSpan */: + case 229 /* TemplateSpan */: + ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 230 /* Block */: + case 231 /* Block */: + ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: + ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: + ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 234 /* IfStatement */: + case 235 /* 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 235 /* DoStatement */: - return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 236 /* WhileStatement */: - return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 237 /* ForStatement */: - return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 238 /* ForInStatement */: - return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 239 /* ForOfStatement */: - return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isToken), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* ContinueStatement */: + case 236 /* DoStatement */: + ts.Debug.type(node); + return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); + case 237 /* WhileStatement */: + ts.Debug.type(node); + return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); + case 238 /* ForStatement */: + ts.Debug.type(node); + return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); + case 239 /* ForInStatement */: + ts.Debug.type(node); + return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); + case 240 /* ForOfStatement */: + ts.Debug.type(node); + return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); + case 241 /* ContinueStatement */: + ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 241 /* BreakStatement */: + case 242 /* BreakStatement */: + ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: + ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 243 /* WithStatement */: + case 244 /* WithStatement */: + ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: + ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: + ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 246 /* ThrowStatement */: + case 247 /* ThrowStatement */: + ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 247 /* TryStatement */: + case 248 /* 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 249 /* VariableDeclaration */: - return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 250 /* VariableDeclarationList */: + case 250 /* VariableDeclaration */: + ts.Debug.type(node); + return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); + case 251 /* VariableDeclarationList */: + ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 251 /* FunctionDeclaration */: - return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), 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 252 /* ClassDeclaration */: + case 252 /* FunctionDeclaration */: + ts.Debug.type(node); + return factory.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); + case 253 /* ClassDeclaration */: + 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 253 /* InterfaceDeclaration */: + case 254 /* 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 254 /* TypeAliasDeclaration */: + case 255 /* 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 255 /* EnumDeclaration */: + case 256 /* 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 256 /* ModuleDeclaration */: - return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 257 /* ModuleBlock */: + case 257 /* ModuleDeclaration */: + ts.Debug.type(node); + return factory.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); + case 258 /* ModuleBlock */: + ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 258 /* CaseBlock */: + case 259 /* CaseBlock */: + ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 259 /* NamespaceExportDeclaration */: + case 260 /* NamespaceExportDeclaration */: + ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 260 /* ImportEqualsDeclaration */: + case 261 /* 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 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: + ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression)); - case 262 /* ImportClause */: + case 263 /* ImportClause */: + ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: + ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamespaceExport */: + case 270 /* NamespaceExport */: + ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 264 /* NamedImports */: + case 265 /* NamedImports */: + ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 265 /* ImportSpecifier */: + case 266 /* ImportSpecifier */: + ts.Debug.type(node); return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 266 /* ExportAssignment */: + case 267 /* 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 267 /* ExportDeclaration */: + case 268 /* 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 268 /* NamedExports */: + case 269 /* NamedExports */: + ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 270 /* ExportSpecifier */: + case 271 /* ExportSpecifier */: + ts.Debug.type(node); return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 272 /* ExternalModuleReference */: + case 273 /* ExternalModuleReference */: + ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 273 /* JsxElement */: + case 274 /* 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 274 /* JsxSelfClosingElement */: + case 275 /* 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 275 /* JsxOpeningElement */: + case 276 /* 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 276 /* JsxClosingElement */: + case 277 /* JsxClosingElement */: + ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 277 /* JsxFragment */: + case 278 /* 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 280 /* JsxAttribute */: + case 281 /* JsxAttribute */: + ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 281 /* JsxAttributes */: + case 282 /* JsxAttributes */: + ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 282 /* JsxSpreadAttribute */: + case 283 /* JsxSpreadAttribute */: + ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: + ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 284 /* CaseClause */: + case 285 /* CaseClause */: + ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 285 /* DefaultClause */: + case 286 /* DefaultClause */: + ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 286 /* HeritageClause */: + case 287 /* HeritageClause */: + ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 287 /* CatchClause */: + case 288 /* CatchClause */: + ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: + ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: + ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 290 /* SpreadAssignment */: + case 291 /* SpreadAssignment */: + ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 291 /* EnumMember */: + case 292 /* 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 297 /* SourceFile */: + case 298 /* SourceFile */: + ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 340 /* PartiallyEmittedExpression */: + ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 337 /* CommaListExpression */: + case 341 /* CommaListExpression */: + ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -82534,7 +84911,7 @@ var ts; function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 297 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 298 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -82585,7 +84962,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -82598,13 +84975,13 @@ var ts; hasImportDefault = true; } break; - case 260 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 272 /* ExternalModuleReference */) { + case 261 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 273 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -82635,13 +85012,13 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -82649,7 +85026,7 @@ var ts; } } break; - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default function() { } @@ -82669,7 +85046,7 @@ var ts; } } break; - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: if (ts.hasSyntacticModifier(node, 1 /* Export */)) { if (ts.hasSyntacticModifier(node, 512 /* Default */)) { // export default class { } @@ -82763,8 +85140,7 @@ var ts; * any such locations */ function isSimpleInlineableExpression(expression) { - return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) || - ts.isWellKnownSymbolSyntactically(expression); + return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression); } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { @@ -82843,10 +85219,19 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 163 /* PropertyDeclaration */ + return member.kind === 164 /* PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; + /** + * Gets a value indicating whether a class element is a private instance method or accessor. + * + * @param member The class element node. + */ + function isNonStaticMethodOrAccessorWithPrivateName(member) { + return !ts.hasStaticModifier(member) && ts.isMethodOrAccessor(member) && ts.isPrivateIdentifier(member.name); + } + ts.isNonStaticMethodOrAccessorWithPrivateName = isNonStaticMethodOrAccessorWithPrivateName; })(ts || (ts = {})); /*@internal*/ var ts; @@ -83120,8 +85505,8 @@ var ts; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 /* ContainsRestOrSpread */ | 16384 /* ContainsObjectRestOrSpread */)) + && !(element.transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (16384 /* ContainsRestOrSpread */ | 32768 /* ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -83187,7 +85572,7 @@ var ts; if (flattenContext.level >= 1 /* ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 16384 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 32768 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -83445,8 +85830,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(202 /* PropertyAccessExpression */); + context.enableSubstitution(203 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -83472,14 +85857,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 298 /* Bundle */) { + if (node.kind === 299 /* 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 === 300 /* InputFiles */) { + if (prepend.kind === 301 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -83530,16 +85915,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 297 /* SourceFile */: - case 258 /* CaseBlock */: - case 257 /* ModuleBlock */: - case 230 /* Block */: + case 298 /* SourceFile */: + case 259 /* CaseBlock */: + case 258 /* ModuleBlock */: + case 231 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: + case 252 /* FunctionDeclaration */: if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { break; } @@ -83551,7 +85936,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 === 252 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 253 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -83594,10 +85979,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 262 /* ImportDeclaration */: + case 261 /* ImportEqualsDeclaration */: + case 267 /* ExportAssignment */: + case 268 /* ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -83618,13 +86003,13 @@ var ts; return node; } switch (node.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -83644,11 +86029,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 267 /* ExportDeclaration */ || - node.kind === 261 /* ImportDeclaration */ || - node.kind === 262 /* ImportClause */ || - (node.kind === 260 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 272 /* ExternalModuleReference */)) { + if (node.kind === 268 /* ExportDeclaration */ || + node.kind === 262 /* ImportDeclaration */ || + node.kind === 263 /* ImportClause */ || + (node.kind === 261 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 273 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -83672,26 +86057,26 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 166 /* Constructor */: + case 167 /* Constructor */: return visitConstructor(node); - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 171 /* IndexSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: + case 172 /* IndexSignature */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 166 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 229 /* SemicolonClassElement */: + case 230 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); } } function modifierVisitor(node) { - if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 18654 /* TypeScriptModifier */) { return undefined; } else if (currentNamespace && node.kind === 92 /* ExportKeyword */) { @@ -83724,13 +86109,13 @@ var ts; case 142 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 178 /* ArrayType */: - case 179 /* TupleType */: - case 180 /* OptionalType */: - case 181 /* RestType */: - case 177 /* TypeLiteral */: - case 172 /* TypePredicate */: - case 159 /* TypeParameter */: + case 179 /* ArrayType */: + case 180 /* TupleType */: + case 181 /* OptionalType */: + case 182 /* RestType */: + case 178 /* TypeLiteral */: + case 173 /* TypePredicate */: + case 160 /* TypeParameter */: case 128 /* AnyKeyword */: case 152 /* UnknownKeyword */: case 131 /* BooleanKeyword */: @@ -83739,43 +86124,43 @@ var ts; case 141 /* NeverKeyword */: case 113 /* VoidKeyword */: case 148 /* SymbolKeyword */: - case 175 /* ConstructorType */: - case 174 /* FunctionType */: - case 176 /* TypeQuery */: - case 173 /* TypeReference */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: - case 184 /* ConditionalType */: - case 186 /* ParenthesizedType */: - case 187 /* ThisType */: - case 188 /* TypeOperator */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 191 /* LiteralType */: + case 176 /* ConstructorType */: + case 175 /* FunctionType */: + case 177 /* TypeQuery */: + case 174 /* TypeReference */: + case 183 /* UnionType */: + case 184 /* IntersectionType */: + case 185 /* ConditionalType */: + case 187 /* ParenthesizedType */: + case 188 /* ThisType */: + case 189 /* TypeOperator */: + case 190 /* IndexedAccessType */: + case 191 /* MappedType */: + case 192 /* LiteralType */: // TypeScript type nodes are elided. // falls through - case 171 /* IndexSignature */: + case 172 /* IndexSignature */: // TypeScript index signatures are elided. // falls through - case 161 /* Decorator */: + case 162 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. // falls through - case 254 /* TypeAliasDeclaration */: + case 255 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 163 /* PropertyDeclaration */: + case 164 /* 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 259 /* NamespaceExportDeclaration */: + case 260 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 166 /* Constructor */: + case 167 /* Constructor */: return visitConstructor(node); - case 253 /* InterfaceDeclaration */: + case 254 /* 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 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83785,7 +86170,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 222 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -83795,35 +86180,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 286 /* HeritageClause */: + case 287 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 167 /* GetAccessor */: + case 168 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 168 /* SetAccessor */: + case 169 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 209 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 160 /* Parameter */: + case 161 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -83833,40 +86218,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 207 /* TypeAssertionExpression */: + case 225 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 203 /* CallExpression */: + case 204 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 205 /* NewExpression */: return visitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 225 /* NonNullExpression */: + case 226 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 274 /* JsxSelfClosingElement */: + case 275 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 275 /* JsxOpeningElement */: + case 276 /* JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -83920,7 +86305,7 @@ var ts; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 2048 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 4096 /* ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.some(node.decorators) @@ -84275,12 +86660,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -84433,7 +86818,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 163 /* PropertyDeclaration */ + ? member.kind === 164 /* 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() @@ -84557,10 +86942,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */ - || kind === 163 /* PropertyDeclaration */; + return kind === 166 /* MethodDeclaration */ + || kind === 168 /* GetAccessor */ + || kind === 169 /* SetAccessor */ + || kind === 164 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -84570,7 +86955,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 165 /* MethodDeclaration */; + return node.kind === 166 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -84581,12 +86966,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return true; } return false; @@ -84603,15 +86988,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 164 /* PropertyDeclaration */: + case 161 /* Parameter */: return serializeTypeNode(node.type); - case 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 169 /* SetAccessor */: + case 168 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 166 /* MethodDeclaration */: return factory.createIdentifier("Function"); default: return factory.createVoidZero(); @@ -84648,7 +87033,7 @@ var ts; return factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 167 /* GetAccessor */) { + if (container && node.kind === 168 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -84697,27 +87082,27 @@ var ts; case 150 /* UndefinedKeyword */: case 141 /* NeverKeyword */: return factory.createVoidZero(); - case 186 /* ParenthesizedType */: + case 187 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: return factory.createIdentifier("Function"); - case 178 /* ArrayType */: - case 179 /* TupleType */: + case 179 /* ArrayType */: + case 180 /* TupleType */: return factory.createIdentifier("Array"); - case 172 /* TypePredicate */: + case 173 /* TypePredicate */: case 131 /* BooleanKeyword */: return factory.createIdentifier("Boolean"); case 147 /* StringKeyword */: return factory.createIdentifier("String"); case 145 /* ObjectKeyword */: return factory.createIdentifier("Object"); - case 191 /* LiteralType */: + case 192 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return factory.createIdentifier("String"); - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return factory.createIdentifier("Number"); case 9 /* BigIntLiteral */: @@ -84738,37 +87123,37 @@ var ts; return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : factory.createIdentifier("Symbol"); - case 173 /* TypeReference */: + case 174 /* TypeReference */: return serializeTypeReferenceNode(node); - case 183 /* IntersectionType */: - case 182 /* UnionType */: + case 184 /* IntersectionType */: + case 183 /* UnionType */: return serializeTypeList(node.types); - case 184 /* ConditionalType */: + case 185 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 188 /* TypeOperator */: + case 189 /* TypeOperator */: if (node.operator === 142 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 176 /* TypeQuery */: - case 189 /* IndexedAccessType */: - case 190 /* MappedType */: - case 177 /* TypeLiteral */: + case 177 /* TypeQuery */: + case 190 /* IndexedAccessType */: + case 191 /* MappedType */: + case 178 /* TypeLiteral */: case 128 /* AnyKeyword */: case 152 /* UnknownKeyword */: - case 187 /* ThisType */: - case 195 /* ImportType */: + case 188 /* ThisType */: + case 196 /* ImportType */: break; // handle JSDoc types from an invalid parse - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: - case 308 /* JSDocFunctionType */: - case 309 /* JSDocVariadicType */: - case 310 /* JSDocNamepathType */: + case 304 /* JSDocAllType */: + case 305 /* JSDocUnknownType */: + case 309 /* JSDocFunctionType */: + case 310 /* JSDocVariadicType */: + case 311 /* JSDocNamepathType */: break; - case 305 /* JSDocNullableType */: - case 306 /* JSDocNonNullableType */: - case 307 /* JSDocOptionalType */: + case 306 /* JSDocNullableType */: + case 307 /* JSDocNonNullableType */: + case 308 /* JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -84781,13 +87166,13 @@ var ts; var serializedUnion; for (var _i = 0, types_24 = types; _i < types_24.length; _i++) { var typeNode = types_24[_i]; - while (typeNode.kind === 186 /* ParenthesizedType */) { + while (typeNode.kind === 187 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 141 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 191 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 192 /* LiteralType */ && typeNode.literal.kind === 103 /* NullKeyword */ || typeNode.kind === 150 /* 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); @@ -84897,7 +87282,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 157 /* QualifiedName */: + case 158 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -85470,12 +87855,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 === 297 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 298 /* 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 === 255 /* EnumDeclaration */) { + if (node.kind === 256 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -85600,7 +87985,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 257 /* ModuleBlock */) { + if (node.body.kind === 258 /* ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -85647,13 +88032,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 257 /* ModuleBlock */) { + if (!node.body || node.body.kind !== 258 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 256 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 257 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -85703,7 +88088,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 263 /* NamespaceImport */) { + if (node.kind === 264 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -85956,16 +88341,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(78 /* Identifier */); - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); + context.enableSubstitution(290 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(256 /* ModuleDeclaration */); + context.enableEmitNotification(257 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 256 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 257 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 255 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 256 /* EnumDeclaration */; } /** * Hook for node emit. @@ -86026,9 +88411,9 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return substituteExpressionIdentifier(node); - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -86050,10 +88435,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_1 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_1, node); - ts.setCommentRange(clone_1, node); - return clone_1; + var clone_2 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_2, node); + ts.setCommentRange(clone_2, node); + return clone_2; } } } @@ -86066,9 +88451,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 !== 297 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 256 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 255 /* EnumDeclaration */); + if (container && container.kind !== 298 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 257 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 256 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -86120,10 +88505,12 @@ var ts; */ ClassPropertySubstitutionFlags[ClassPropertySubstitutionFlags["ClassAliases"] = 1] = "ClassAliases"; })(ClassPropertySubstitutionFlags || (ClassPropertySubstitutionFlags = {})); - var PrivateIdentifierPlacement; - (function (PrivateIdentifierPlacement) { - PrivateIdentifierPlacement[PrivateIdentifierPlacement["InstanceField"] = 0] = "InstanceField"; - })(PrivateIdentifierPlacement || (PrivateIdentifierPlacement = {})); + var PrivateIdentifierKind; + (function (PrivateIdentifierKind) { + PrivateIdentifierKind["Field"] = "f"; + PrivateIdentifierKind["Method"] = "m"; + PrivateIdentifierKind["Accessor"] = "a"; + })(PrivateIdentifierKind = ts.PrivateIdentifierKind || (ts.PrivateIdentifierKind = {})); /** * Transforms ECMAScript Class Syntax. * TypeScript parameter property syntax is transformed in the TypeScript transformer. @@ -86132,11 +88519,12 @@ var ts; * When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty. */ function transformClassFields(context) { - var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment; + var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, addBlockScopedVariable = context.addBlockScopedVariable; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var shouldTransformPrivateFields = languageVersion < 99 /* ESNext */; + var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); + var shouldTransformPrivateElements = languageVersion < 99 /* ESNext */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var enabledSubstitutions; @@ -86157,7 +88545,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || options.useDefineForClassFields && options.target === 99 /* ESNext */) { + || useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -86165,41 +88553,41 @@ var ts; return visited; } function visitor(node) { - if (!(node.transformFlags & 4194304 /* ContainsClassFields */)) + if (!(node.transformFlags & 8388608 /* ContainsClassFields */)) return node; switch (node.kind) { - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 253 /* ClassDeclaration */: return visitClassLike(node); - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return visitVariableStatement(node); - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: return visitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: return visitPostfixUnaryExpression(node, /*valueIsDiscarded*/ false); - case 203 /* CallExpression */: + case 204 /* CallExpression */: return visitCallExpression(node); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return visitBinaryExpression(node); case 79 /* PrivateIdentifier */: return visitPrivateIdentifier(node); - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: return visitExpressionStatement(node); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return visitForStatement(node); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); } return ts.visitEachChild(node, visitor, context); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 200 /* ObjectLiteralExpression */: - case 199 /* ArrayLiteralExpression */: + case 201 /* ObjectLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -86210,7 +88598,7 @@ var ts; * Replace it with an empty identifier to indicate a problem with the code. */ function visitPrivateIdentifier(node) { - if (!shouldTransformPrivateFields) { + if (!shouldTransformPrivateElements) { return node; } return ts.setOriginalNode(factory.createIdentifier(""), node); @@ -86222,20 +88610,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 166 /* Constructor */: + case 167 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - // Visit the name of the member (if it's a computed property name). - return ts.visitEachChild(node, classElementVisitor, context); - case 163 /* PropertyDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 166 /* MethodDeclaration */: + return visitMethodOrAccessorDeclaration(node); + case 164 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 229 /* SemicolonClassElement */: + case 230 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -86260,44 +88647,96 @@ var ts; } return node; } + function visitMethodOrAccessorDeclaration(node) { + ts.Debug.assert(!ts.some(node.decorators)); + if (!shouldTransformPrivateElements || !ts.isPrivateIdentifier(node.name)) { + return ts.visitEachChild(node, classElementVisitor, context); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } + var functionName = getHoistedFunctionName(node); + if (functionName) { + getPendingExpressions().push(factory.createAssignment(functionName, factory.createFunctionExpression(ts.filter(node.modifiers, function (m) { return !ts.isStaticModifier(m); }), node.asteriskToken, functionName, + /* typeParameters */ undefined, ts.visitParameterList(node.parameters, classElementVisitor, context), + /* type */ undefined, ts.visitFunctionBody(node.body, classElementVisitor, context)))); + } + // remove method declaration from class + return undefined; + } + function getHoistedFunctionName(node) { + ts.Debug.assert(ts.isPrivateIdentifier(node.name)); + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (info.kind === "m" /* Method */) { + return info.methodName; + } + if (info.kind === "a" /* Accessor */) { + if (ts.isGetAccessor(node)) { + return info.getterName; + } + if (ts.isSetAccessor(node)) { + return info.setterName; + } + } + } function visitPropertyDeclaration(node) { ts.Debug.assert(!ts.some(node.decorators)); - if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { - // Initializer is elided as the field is initialized in transformConstructor. - return factory.updatePropertyDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, - /*questionOrExclamationToken*/ undefined, - /*type*/ undefined, - /*initializer*/ undefined); + if (ts.isPrivateIdentifier(node.name)) { + if (!shouldTransformPrivateElements) { + // Initializer is elided as the field is initialized in transformConstructor. + return factory.updatePropertyDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, + /*questionOrExclamationToken*/ undefined, + /*type*/ undefined, + /*initializer*/ undefined); + } + // leave invalid code untransformed + var info = accessPrivateIdentifier(node.name); + ts.Debug.assert(info, "Undeclared private name for property declaration."); + if (!info.isValid) { + return node; + } } // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { getPendingExpressions().push(expr); } return undefined; } function createPrivateIdentifierAccess(info, receiver) { - receiver = ts.visitNode(receiver, visitor, ts.isExpression); - switch (info.placement) { - case 0 /* InstanceField */: - return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver), info.weakMapName); - default: return ts.Debug.fail("Unexpected private identifier placement"); + return createPrivateIdentifierAccessHelper(info, ts.visitNode(receiver, visitor, ts.isExpression)); + } + function createPrivateIdentifierAccessHelper(info, receiver) { + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } function visitPropertyAccessExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(node.name)) { var privateIdentifierInfo = accessPrivateIdentifier(node.name); if (privateIdentifierInfo) { - return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node), node); } } return ts.visitEachChild(node, visitor, context); } function visitPrefixUnaryExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -86312,7 +88751,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPostfixUnaryExpression(node, valueIsDiscarded) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { var operator = node.operator === 45 /* PlusPlusToken */ ? 39 /* PlusToken */ : node.operator === 46 /* MinusMinusToken */ ? 40 /* MinusToken */ : undefined; @@ -86333,7 +88772,7 @@ var ts; } function visitForStatement(node) { if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) { - return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitNode(node.statement, visitor, ts.isStatement)); + return factory.updateForStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), visitPostfixUnaryExpression(node.incrementor, /*valueIsDiscarded*/ true), ts.visitIterationBody(node.statement, visitor, context)); } return ts.visitEachChild(node, visitor, context); } @@ -86353,7 +88792,7 @@ var ts; return { readExpression: readExpression, initializeExpression: initializeExpression }; } function visitCallExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) { // Transform call expressions of private names to properly bind the `this` parameter. var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; if (ts.isCallChain(node)) { @@ -86367,7 +88806,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitTaggedTemplateExpression(node) { - if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) { // Bind the `this` correctly for tagged template literals when the tag is a private identifier property access. var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target; return factory.updateTaggedTemplateExpression(node, factory.createCallExpression(factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "bind"), @@ -86377,7 +88816,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitBinaryExpression(node) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { if (ts.isDestructuringAssignment(node)) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; @@ -86391,29 +88830,31 @@ var ts; if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) { var info = accessPrivateIdentifier(node.left.name); if (info) { - return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node); + return ts.setTextRange(ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node), node); } } } return ts.visitEachChild(node, visitor, context); } function createPrivateIdentifierAssignment(info, receiver, right, operator) { - switch (info.placement) { - case 0 /* InstanceField */: { - return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator); - } - default: return ts.Debug.fail("Unexpected private identifier placement"); - } - } - function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) { receiver = ts.visitNode(receiver, visitor, ts.isExpression); right = ts.visitNode(right, visitor, ts.isExpression); if (ts.isCompoundAssignment(operator)) { var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(initializeExpression || readExpression, info.weakMapName, factory.createBinaryExpression(context.getEmitHelperFactory().createClassPrivateFieldGetHelper(readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right)); - } - else { - return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.weakMapName, right); + receiver = initializeExpression || readExpression; + right = factory.createBinaryExpression(createPrivateIdentifierAccessHelper(info, readExpression), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right); + } + ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); + switch (info.kind) { + case "a" /* Accessor */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); + case "m" /* Method */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, + /* f */ undefined); + case "f" /* Field */: + return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); + default: + ts.Debug.assertNever(info, "Unknown private element type"); } } /** @@ -86422,25 +88863,43 @@ var ts; function visitClassLike(node) { var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { startPrivateIdentifierEnvironment(); + var name = ts.getNameOfDeclaration(node); + if (name && ts.isIdentifier(name)) { + getPrivateIdentifierEnvironment().className = ts.idText(name); + } + var privateInstanceMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + if (ts.some(privateInstanceMethodsAndAccessors)) { + getPrivateIdentifierEnvironment().weakSetName = createHoistedVariableForClass("instances", privateInstanceMethodsAndAccessors[0].name); + } } var result = ts.isClassDeclaration(node) ? visitClassDeclaration(node) : visitClassExpression(node); - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { endPrivateIdentifierEnvironment(); } pendingExpressions = savedPendingExpressions; return result; } function doesClassElementNeedTransform(node) { - return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name)); + return ts.isPropertyDeclaration(node) || (shouldTransformPrivateElements && node.name && ts.isPrivateIdentifier(node.name)); + } + function getPrivateInstanceMethodsAndAccessors(node) { + return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function visitClassDeclaration(node) { if (!ts.forEach(node.members, doesClassElementNeedTransform)) { return ts.visitEachChild(node, visitor, context); } + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); + var pendingPrivateStateAssignment; + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + var temp = factory.createTempVariable(hoistVariableDeclaration, /* reservedInNestedScopes */ true); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + pendingPrivateStateAssignment = factory.createAssignment(temp, factory.getInternalName(node)); + } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); var statements = [ @@ -86448,6 +88907,9 @@ var ts; /*decorators*/ undefined, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; + if (pendingPrivateStateAssignment) { + getPendingExpressions().unshift(pendingPrivateStateAssignment); + } // Write any pending expressions from elided or moved computed property names if (ts.some(pendingExpressions)) { statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))); @@ -86457,7 +88919,6 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { addPropertyStatements(statements, staticProperties, factory.getInternalName(node)); } @@ -86475,12 +88936,25 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103 /* NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var temp; + function createClassTempVar() { + var classCheckFlags = resolver.getNodeCheckFlags(node); + var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); + } + if (shouldTransformPrivateElements && ts.some(node.members, function (m) { return ts.hasStaticModifier(m) && !!m.name && ts.isPrivateIdentifier(m.name); })) { + temp = createClassTempVar(); + getPrivateIdentifierEnvironment().classConstructor = factory.cloneNode(temp); + } var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); - if (ts.some(staticProperties) || ts.some(pendingExpressions)) { + var hasTransformableStatics = ts.some(staticProperties, function (p) { return !!p.initializer || (shouldTransformPrivateElements && ts.isPrivateIdentifier(p.name)); }); + if (hasTransformableStatics || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); // Write any pending expressions from elided or moved computed property names @@ -86490,12 +88964,14 @@ var ts; if (pendingStatements && ts.some(staticProperties)) { addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node)); } + if (temp) { + return factory.inlineExpressions([factory.createAssignment(temp, classExpression), temp]); + } return classExpression; } else { var expressions = []; - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; - var temp = factory.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference); + temp || (temp = createClassTempVar()); if (isClassWithConstructorReference) { // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); @@ -86517,14 +88993,17 @@ var ts; return classExpression; } function transformClassMembers(node, isDerivedClass) { - if (shouldTransformPrivateFields) { + if (shouldTransformPrivateElements) { // Declare private names. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.isPrivateIdentifierPropertyDeclaration(member)) { - addPrivateIdentifierToEnvironment(member.name); + if (ts.isPrivateIdentifierClassElementDeclaration(member)) { + addPrivateIdentifierToEnvironment(member); } } + if (ts.some(getPrivateInstanceMethodsAndAccessors(node))) { + createBrandCheckWeakSetForPrivateMethods(); + } } var members = []; var constructor = transformConstructor(node, isDerivedClass); @@ -86534,21 +89013,27 @@ var ts; ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement)); return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members); } - function isPropertyDeclarationThatRequiresConstructorStatement(member) { - if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + function createBrandCheckWeakSetForPrivateMethods() { + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + getPendingExpressions().push(factory.createAssignment(weakSetName, factory.createNewExpression(factory.createIdentifier("WeakSet"), + /*typeArguments*/ undefined, []))); + } + function isClassElementThatRequiresConstructorStatement(member) { + if (ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { return false; } - if (context.getCompilerOptions().useDefineForClassFields) { + if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. return languageVersion < 99 /* ESNext */; } - return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member); + return ts.isInitializedProperty(member) || shouldTransformPrivateElements && ts.isPrivateIdentifierClassElementDeclaration(member); } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement); - if (!ts.some(properties)) { + var elements = node.members.filter(isClassElementThatRequiresConstructorStatement); + if (!ts.some(elements)) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -86561,13 +89046,14 @@ var ts; /*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields; var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false); if (!useDefineForClassFields) { properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); }); } + var privateMethodsAndAccessors = getPrivateInstanceMethodsAndAccessors(node); + var needsConstructorBody = ts.some(properties) || ts.some(privateMethodsAndAccessors); // Only generate synthetic constructor when there are property initializers to move. - if (!constructor && !ts.some(properties)) { + if (!constructor && !needsConstructorBody) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); } resumeLexicalEnvironment(); @@ -86606,7 +89092,10 @@ var ts; indexOfFirstStatement = afterParameterProperties; } } - addPropertyStatements(statements, properties, factory.createThis()); + var receiver = factory.createThis(); + // private methods can be called in property initializers, they should execute first. + addMethodStatements(statements, privateMethodsAndAccessors, receiver); + addPropertyStatements(statements, properties, receiver); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -86668,27 +89157,30 @@ var ts; function transformProperty(property, receiver) { var _a; // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) - var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; + var emitAssignment = !useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name)) : property.name; - if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) { + if (shouldTransformPrivateElements && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - switch (privateIdentifierInfo.placement) { - case 0 /* InstanceField */: { - return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName); + if (privateIdentifierInfo.kind === "f" /* Field */) { + if (!privateIdentifierInfo.isStatic) { + return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); + } + else { + return createPrivateStaticFieldInitializer(privateIdentifierInfo.variableName, ts.visitNode(property.initializer, visitor, ts.isExpression)); } } + else { + return undefined; + } } else { ts.Debug.fail("Undeclared private name for property declaration."); } } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { - return undefined; - } - if (ts.isPrivateIdentifier(propertyName) && !property.initializer) { + if ((ts.isPrivateIdentifier(propertyName) || ts.hasStaticModifier(property)) && !property.initializer) { return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); @@ -86720,6 +89212,21 @@ var ts; classAliases = []; } } + /** + * Generates brand-check initializer for private methods. + * + * @param statements Statement list that should be used to append new statements. + * @param methods An array of method declarations. + * @param receiver The receiver on which each method should be assigned. + */ + function addMethodStatements(statements, methods, receiver) { + if (!shouldTransformPrivateElements || !ts.some(methods)) { + return; + } + var weakSetName = getPrivateIdentifierEnvironment().weakSetName; + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + statements.push(factory.createExpressionStatement(createPrivateInstanceMethodInitializer(receiver, weakSetName))); + } /** * Hooks node substitutions. * @@ -86755,10 +89262,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { - var clone_2 = factory.cloneNode(classAlias); - ts.setSourceMapRange(clone_2, node); - ts.setCommentRange(clone_2, node); - return clone_2; + var clone_3 = factory.cloneNode(classAlias); + ts.setSourceMapRange(clone_3, node); + ts.setCommentRange(clone_3, node); + return clone_3; } } } @@ -86778,7 +89285,12 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - hoistVariableDeclaration(generatedName); + if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + addBlockScopedVariable(generatedName); + } + else { + hoistVariableDeclaration(generatedName); + } return factory.createAssignment(generatedName, expression); } return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression; @@ -86792,22 +89304,164 @@ var ts; currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop(); } function getPrivateIdentifierEnvironment() { - return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new ts.Map()); + if (!currentPrivateIdentifierEnvironment) { + currentPrivateIdentifierEnvironment = { + className: "", + identifiers: new ts.Map() + }; + } + return currentPrivateIdentifierEnvironment; } function getPendingExpressions() { return pendingExpressions || (pendingExpressions = []); } - function addPrivateIdentifierToEnvironment(name) { - var text = ts.getTextOfPropertyName(name); - var weakMapName = factory.createUniqueName("_" + text.substring(1), 16 /* Optimistic */ | 8 /* ReservedInNestedScopes */); - hoistVariableDeclaration(weakMapName); - getPrivateIdentifierEnvironment().set(name.escapedText, { placement: 0 /* InstanceField */, weakMapName: weakMapName }); - getPendingExpressions().push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), - /*typeArguments*/ undefined, []))); + function addPrivateIdentifierToEnvironment(node) { + var _a; + var text = ts.getTextOfPropertyName(node.name); + var env = getPrivateIdentifierEnvironment(); + var weakSetName = env.weakSetName, classConstructor = env.classConstructor; + var assignmentExpressions = []; + var privateName = node.name.escapedText; + var previousInfo = env.identifiers.get(privateName); + var isValid = !isReservedPrivateName(node.name) && previousInfo === undefined; + if (ts.hasStaticModifier(node)) { + ts.Debug.assert(classConstructor, "weakSetName should be set in private identifier environment"); + if (ts.isPropertyDeclaration(node)) { + var variableName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + variableName: variableName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + else if (ts.isMethodDeclaration(node)) { + var functionName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: functionName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + else if (ts.isGetAccessorDeclaration(node)) { + var getterName = createHoistedVariableForPrivateName(text + "_get", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + else if (ts.isSetAccessorDeclaration(node)) { + var setterName = createHoistedVariableForPrivateName(text + "_set", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: classConstructor, + isStatic: true, + isValid: isValid, + }); + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + } + else if (ts.isPropertyDeclaration(node)) { + var weakMapName = createHoistedVariableForPrivateName(text, node); + env.identifiers.set(privateName, { + kind: "f" /* Field */, + brandCheckIdentifier: weakMapName, + isStatic: false, + variableName: undefined, + isValid: isValid, + }); + assignmentExpressions.push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), + /*typeArguments*/ undefined, []))); + } + else if (ts.isMethodDeclaration(node)) { + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + env.identifiers.set(privateName, { + kind: "m" /* Method */, + methodName: createHoistedVariableForPrivateName(text, node), + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + else if (ts.isAccessor(node)) { + ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); + if (ts.isGetAccessor(node)) { + var getterName = createHoistedVariableForPrivateName(text + "_get", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + previousInfo.getterName = getterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: getterName, + setterName: undefined, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + else { + var setterName = createHoistedVariableForPrivateName(text + "_set", node); + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + previousInfo.setterName = setterName; + } + else { + env.identifiers.set(privateName, { + kind: "a" /* Accessor */, + getterName: undefined, + setterName: setterName, + brandCheckIdentifier: weakSetName, + isStatic: false, + isValid: isValid, + }); + } + } + } + else { + ts.Debug.assertNever(node, "Unknown class element type."); + } + (_a = getPendingExpressions()).push.apply(_a, assignmentExpressions); + } + function createHoistedVariableForClass(name, node) { + var className = getPrivateIdentifierEnvironment().className; + var prefix = className ? "_" + className : ""; + var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + addBlockScopedVariable(identifier); + } + else { + hoistVariableDeclaration(identifier); + } + return identifier; + } + function createHoistedVariableForPrivateName(privateName, node) { + return createHoistedVariableForClass(privateName.substring(1), node.name); } function accessPrivateIdentifier(name) { if (currentPrivateIdentifierEnvironment) { - var info = currentPrivateIdentifierEnvironment.get(name.escapedText); + var info = currentPrivateIdentifierEnvironment.identifiers.get(name.escapedText); if (info) { return info; } @@ -86817,7 +89471,7 @@ var ts; if (!env) { continue; } - var info = env.get(name.escapedText); + var info = env.identifiers.get(name.escapedText); if (info) { return info; } @@ -86903,10 +89557,22 @@ var ts; } } ts.transformClassFields = transformClassFields; + function createPrivateStaticFieldInitializer(variableName, initializer) { + return ts.factory.createAssignment(variableName, ts.factory.createObjectLiteralExpression([ + ts.factory.createPropertyAssignment("value", initializer || ts.factory.createVoidZero()) + ])); + } function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) { return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakMapName, "set"), /*typeArguments*/ undefined, [receiver, initializer || ts.factory.createVoidZero()]); } + function createPrivateInstanceMethodInitializer(receiver, weakSetName) { + return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakSetName, "add"), + /*typeArguments*/ undefined, [receiver]); + } + function isReservedPrivateName(node) { + return node.escapedText === "#constructor"; + } })(ts || (ts = {})); /*@internal*/ var ts; @@ -86989,38 +89655,38 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 128 /* ContainsES2017 */) === 0) { return node; } switch (node.kind) { case 129 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 213 /* AwaitExpression */: + case 214 /* AwaitExpression */: return visitAwaitExpression(node); - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 208 /* FunctionExpression */: + case 209 /* FunctionExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 167 /* Constructor */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -87029,27 +89695,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 239 /* ForOfStatement */: + case 240 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 287 /* CatchClause */: + case 288 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 230 /* Block */: - case 244 /* SwitchStatement */: - case 258 /* CaseBlock */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 243 /* WithStatement */: - case 245 /* LabeledStatement */: + case 231 /* Block */: + case 245 /* SwitchStatement */: + case 259 /* CaseBlock */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: + case 248 /* TryStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: + case 235 /* IfStatement */: + case 244 /* WithStatement */: + case 246 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -87091,18 +89757,18 @@ var ts; function visitForInStatementInAsyncBody(node) { return factory.updateForInStatement(node, isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForOfStatementInAsyncBody(node) { return factory.updateForOfStatement(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer) ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ true) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } function visitForStatementInAsyncBody(node) { var initializer = node.initializer; // TODO: GH#18217 return factory.updateForStatement(node, isVariableDeclarationListWithCollidingName(initializer) ? visitVariableDeclarationListWithCollidingNames(initializer, /*hasReceiver*/ false) - : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock)); + : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, asyncBodyVisitor, context)); } /** * Visits an AwaitExpression node. @@ -87254,7 +89920,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 === 209 /* ArrowFunction */; + var isArrowFunction = node.kind === 210 /* 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 @@ -87345,17 +90011,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(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(204 /* CallExpression */); + context.enableSubstitution(202 /* PropertyAccessExpression */); + context.enableSubstitution(203 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(253 /* ClassDeclaration */); + context.enableEmitNotification(166 /* MethodDeclaration */); + context.enableEmitNotification(168 /* GetAccessor */); + context.enableEmitNotification(169 /* SetAccessor */); + context.enableEmitNotification(167 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(233 /* VariableStatement */); } } /** @@ -87403,11 +90069,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 204 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -87439,11 +90105,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 253 /* ClassDeclaration */ + || kind === 167 /* Constructor */ + || kind === 166 /* MethodDeclaration */ + || kind === 168 /* GetAccessor */ + || kind === 169 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -87622,74 +90288,74 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 32 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 64 /* ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 213 /* AwaitExpression */: + case 214 /* AwaitExpression */: return visitAwaitExpression(node); - case 219 /* YieldExpression */: + case 220 /* YieldExpression */: return visitYieldExpression(node); - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: return visitReturnStatement(node); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return visitLabeledStatement(node); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 341 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 287 /* CatchClause */: + case 288 /* CatchClause */: return visitCatchClause(node); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return visitVariableStatement(node); - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: + case 239 /* ForInStatement */: return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 239 /* ForOfStatement */: + case 240 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 212 /* VoidExpression */: + case 213 /* VoidExpression */: return visitVoidExpression(node); - case 166 /* Constructor */: + case 167 /* Constructor */: return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 167 /* GetAccessor */: + case 168 /* GetAccessor */: return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 168 /* SetAccessor */: + case 169 /* SetAccessor */: return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 208 /* FunctionExpression */: + case 209 /* FunctionExpression */: return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 160 /* Parameter */: + case 161 /* Parameter */: return visitParameter(node); - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: return visitExpressionStatement(node); - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105 /* SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: if (capturedSuperProperties && node.expression.kind === 105 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); @@ -87725,7 +90391,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 239 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 240 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -87737,7 +90403,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 === 290 /* SpreadAssignment */) { + if (e.kind === 291 /* SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -87746,7 +90412,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 288 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 289 /* PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -87757,7 +90423,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -87780,7 +90446,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 !== 200 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 201 /* ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -87830,7 +90496,7 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); } if (node.operatorToken.kind === 27 /* CommaToken */) { @@ -87861,7 +90527,7 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); @@ -87902,14 +90568,14 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); } function visitForStatement(node) { - return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement)); + return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); } function visitVoidExpression(node) { return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context); @@ -87921,7 +90587,7 @@ var ts; */ function visitForOfStatement(node, outermostLabeledStatement) { var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.initializer.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -87959,7 +90625,7 @@ var ts; var bodyLocation; var statementsLocation; var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var statement = ts.visitIterationBody(node.statement, visitor, context); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -88021,7 +90687,7 @@ var ts; ])); } function visitParameter(node) { - if (node.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -88173,7 +90839,7 @@ var ts; function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - if (parameter.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { + if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) { var temp = factory.getGeneratedNameForNode(parameter); var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp, /*doNotRecordTempVariablesInLine*/ false, @@ -88193,17 +90859,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(203 /* CallExpression */); - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(202 /* ElementAccessExpression */); + context.enableSubstitution(204 /* CallExpression */); + context.enableSubstitution(202 /* PropertyAccessExpression */); + context.enableSubstitution(203 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(252 /* ClassDeclaration */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(166 /* Constructor */); + context.enableEmitNotification(253 /* ClassDeclaration */); + context.enableEmitNotification(166 /* MethodDeclaration */); + context.enableEmitNotification(168 /* GetAccessor */); + context.enableEmitNotification(169 /* SetAccessor */); + context.enableEmitNotification(167 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(232 /* VariableStatement */); + context.enableEmitNotification(233 /* VariableStatement */); } } /** @@ -88251,11 +90917,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 203 /* CallExpression */: + case 204 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -88287,11 +90953,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 252 /* ClassDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 253 /* ClassDeclaration */ + || kind === 167 /* Constructor */ + || kind === 166 /* MethodDeclaration */ + || kind === 168 /* GetAccessor */ + || kind === 169 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -88319,11 +90985,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 32 /* ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 287 /* CatchClause */: + case 288 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -88351,25 +91017,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 8 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 16 /* ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: - case 203 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 204 /* CallExpression */: { + var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + case 202 /* PropertyAccessExpression */: + case 203 /* 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 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 210 /* DeleteExpression */: + case 211 /* DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88411,7 +91081,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 201 /* PropertyAccessExpression */ + expression = node.kind === 202 /* 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; @@ -88421,14 +91091,23 @@ var ts; // If `node` is an optional chain, then it is the outermost chain of an optional expression. return visitOptionalExpression(node, captureThisArg, /*isDelete*/ false); } + if (ts.isParenthesizedExpression(node.expression) && ts.isOptionalChain(ts.skipParentheses(node.expression))) { + // capture thisArg for calls of parenthesized optional chains like `(foo?.bar)()` + var expression = visitNonOptionalParenthesizedExpression(node.expression, /*captureThisArg*/ true, /*isDelete*/ false); + var args = ts.visitNodes(node.arguments, visitor, ts.isExpression); + if (ts.isSyntheticReference(expression)) { + return ts.setTextRange(factory.createFunctionCallCall(expression.expression, expression.thisArg, args), node); + } + return factory.updateCallExpression(node, expression, /*typeArguments*/ undefined, args); + } return ts.visitEachChild(node, visitor, context); } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 203 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 208 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 204 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -88447,8 +91126,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -88458,11 +91137,11 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 201 /* PropertyAccessExpression */ + rightExpression = segment.kind === 202 /* PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 203 /* CallExpression */: + case 204 /* CallExpression */: if (i === 0 && leftThisArg) { rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } @@ -88505,7 +91184,7 @@ var ts; /*@internal*/ var ts; (function (ts) { - function transformESNext(context) { + function transformES2021(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration, factory = context.factory; return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { @@ -88515,11 +91194,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 8 /* ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -88555,6 +91234,29 @@ var ts; return factory.createBinaryExpression(left, nonAssignmentOperator, factory.createParenthesizedExpression(factory.createAssignment(assignmentTarget, right))); } } + ts.transformES2021 = transformES2021; +})(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + function transformESNext(context) { + return ts.chainBundle(context, transformSourceFile); + function transformSourceFile(node) { + if (node.isDeclarationFile) { + return node; + } + return ts.visitEachChild(node, visitor, context); + } + function visitor(node) { + if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + return node; + } + switch (node.kind) { + default: + return ts.visitEachChild(node, visitor, context); + } + } + } ts.transformESNext = transformESNext; })(ts || (ts = {})); /*@internal*/ @@ -88665,13 +91367,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 273 /* JsxElement */: + case 274 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 274 /* JsxSelfClosingElement */: + case 275 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 277 /* JsxFragment */: + case 278 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -88681,13 +91383,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: return visitJsxExpression(node); - case 273 /* JsxElement */: + case 274 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 274 /* JsxSelfClosingElement */: + case 275 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 277 /* JsxFragment */: + case 278 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -88727,9 +91429,9 @@ var ts; function convertJsxChildrenToChildrenPropObject(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) + var result_14 = transformJsxChildToExpression(nonWhitespaceChildren[0]); + return result_14 && factory.createObjectLiteralExpression([ + factory.createPropertyAssignment("children", result_14) ]); } var result = ts.mapDefined(children, transformJsxChildToExpression); @@ -88805,21 +91507,29 @@ var ts; // When there are no attributes, React wants "null" } 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()); + 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); + }))); } - // 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); + 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 callee = currentFileState.importSpecifier === undefined @@ -88851,6 +91561,9 @@ var ts; } return element; } + function transformJsxSpreadAttributeToSpreadAssignment(node) { + return factory.createSpreadAssignment(ts.visitNode(node.expression, visitor, ts.isExpression)); + } function transformJsxSpreadAttributeToExpression(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } @@ -88870,7 +91583,7 @@ var ts; var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - else if (node.kind === 283 /* JsxExpression */) { + else if (node.kind === 284 /* JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -88964,7 +91677,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 273 /* JsxElement */) { + if (node.kind === 274 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -89266,11 +91979,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 128 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 256 /* ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89483,11 +92196,11 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 242 /* ReturnStatement */ + && node.kind === 243 /* ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 1048576 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 2097152 /* ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -89502,7 +92215,7 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 256 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 512 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) @@ -89524,65 +92237,65 @@ var ts; switch (node.kind) { case 123 /* StaticKeyword */: return undefined; // elide static keyword - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: return visitClassDeclaration(node); - case 221 /* ClassExpression */: + case 222 /* ClassExpression */: return visitClassExpression(node); - case 160 /* Parameter */: + case 161 /* Parameter */: return visitParameter(node); - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return visitArrowFunction(node); - case 208 /* FunctionExpression */: + case 209 /* FunctionExpression */: return visitFunctionExpression(node); - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return visitVariableDeclaration(node); case 78 /* Identifier */: return visitIdentifier(node); - case 250 /* VariableDeclarationList */: + case 251 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 259 /* CaseBlock */: return visitCaseBlock(node); - case 230 /* Block */: + case 231 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 242 /* BreakStatement */: + case 241 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return visitLabeledStatement(node); - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 239 /* ForOfStatement */: + case 240 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: return visitExpressionStatement(node); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 287 /* CatchClause */: + case 288 /* CatchClause */: return visitCatchClause(node); - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 203 /* CallExpression */: + case 204 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 205 /* NewExpression */: return visitNewExpression(node); - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 337 /* CommaListExpression */: + case 341 /* CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -89593,30 +92306,30 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 218 /* TemplateExpression */: + case 219 /* TemplateExpression */: return visitTemplateExpression(node); - case 219 /* YieldExpression */: + case 220 /* YieldExpression */: return visitYieldExpression(node); - case 220 /* SpreadElement */: + case 221 /* SpreadElement */: return visitSpreadElement(node); case 105 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 107 /* ThisKeyword */: return visitThisKeyword(node); - case 226 /* MetaProperty */: + case 227 /* MetaProperty */: return visitMetaProperty(node); - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return visitVariableStatement(node); - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: return visitReturnStatement(node); - case 212 /* VoidExpression */: + case 213 /* VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -89706,14 +92419,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 === 241 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 242 /* 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 === 241 /* BreakStatement */) { + if (node.kind === 242 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -89724,7 +92437,7 @@ var ts; } } else { - if (node.kind === 241 /* BreakStatement */) { + if (node.kind === 242 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -90036,7 +92749,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass) { - if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096 /* ContainsLexicalThis */)) { + if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -90122,11 +92835,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 242 /* ReturnStatement */) { + if (statement.kind === 243 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 234 /* IfStatement */) { + else if (statement.kind === 235 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -90134,7 +92847,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 230 /* Block */) { + else if (statement.kind === 231 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -90336,7 +93049,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 209 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 210 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -90358,22 +93071,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return statements; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 166 /* Constructor */: + case 167 /* 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 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 101 /* InstanceOfKeyword */, factory.getLocalName(node))), @@ -90408,20 +93121,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 229 /* SemicolonClassElement */: + case 230 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 166 /* Constructor */: + case 167 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -90450,7 +93163,7 @@ var ts; var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); var e; - if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) { + if (!ts.isPrivateIdentifier(propertyName) && ts.getUseDefineForClassFields(context.getCompilerOptions())) { var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) : propertyName; @@ -90542,7 +93255,7 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 4096 /* ContainsLexicalThis */) { + if (node.transformFlags & 8192 /* ContainsLexicalThis */) { hierarchyFacts |= 32768 /* CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; @@ -90624,7 +93337,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 251 /* FunctionDeclaration */ || node.kind === 208 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 252 /* FunctionDeclaration */ || node.kind === 209 /* FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -90670,7 +93383,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 209 /* ArrowFunction */); + ts.Debug.assert(node.kind === 210 /* 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 @@ -90831,7 +93544,7 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 131072 /* ContainsBindingPattern */) { + if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 262144 /* ContainsBindingPattern */) { if (node.flags & 3 /* BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } @@ -90844,7 +93557,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 131072 /* ContainsBindingPattern */ + if (node.transformFlags & 262144 /* ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -90856,8 +93569,8 @@ var ts; // declarations may not be sorted by position. // pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes. var pos = -1, end = -1; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var node = declarations_10[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var node = declarations_9[_i]; pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos); end = Math.max(end, node.end); } @@ -90977,14 +93690,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 239 /* ForOfStatement */: + case 240 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -91168,9 +93881,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 262144 /* ContainsYield */ && + if ((property.transformFlags & 524288 /* ContainsYield */ && hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158 /* ComputedPropertyName */)) { + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 159 /* ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -91273,24 +93986,24 @@ var ts; loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts); } else { - var clone_3 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); - loop = factory.restoreEnclosingLabel(clone_3, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_4 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, /*multiLine*/ true)); + loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); } } else { - var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel); + var clone_5 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + loop = factory.restoreEnclosingLabel(clone_5, outermostLabeledStatement, convertedLoopState && resetLabel); } statements.push(loop); return statements; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 237 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 238 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 239 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 235 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 236 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 238 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 239 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 240 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 236 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 237 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -91315,11 +94028,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 250 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 251 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -91439,7 +94152,7 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.initializer.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 0 /* None */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91554,7 +94267,7 @@ var ts; var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 262144 /* ContainsYield */) !== 0; + var containsYield = (node.statement.transformFlags & 524288 /* ContainsYield */) !== 0; var emitFlags = 524288 /* ReuseTempVariableScope */; if (currentState.containsLexicalThis) emitFlags |= 8 /* CapturesThis */; @@ -91727,20 +94440,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -91847,7 +94560,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 167 /* GetAccessor */) { + if (node.kind === 168 /* GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -92027,7 +94740,7 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 8192 /* ContainsRestOrSpread */ || + if (node.transformFlags & 16384 /* ContainsRestOrSpread */ || node.expression.kind === 105 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; @@ -92035,7 +94748,7 @@ var ts; ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 8192 /* ContainsRestOrSpread */) { + if (node.transformFlags & 16384 /* ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -92353,13 +95066,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(107 /* ThisKeyword */); - context.enableEmitNotification(166 /* Constructor */); - context.enableEmitNotification(165 /* MethodDeclaration */); - context.enableEmitNotification(167 /* GetAccessor */); - context.enableEmitNotification(168 /* SetAccessor */); - context.enableEmitNotification(209 /* ArrowFunction */); - context.enableEmitNotification(208 /* FunctionExpression */); - context.enableEmitNotification(251 /* FunctionDeclaration */); + context.enableEmitNotification(167 /* Constructor */); + context.enableEmitNotification(166 /* MethodDeclaration */); + context.enableEmitNotification(168 /* GetAccessor */); + context.enableEmitNotification(169 /* SetAccessor */); + context.enableEmitNotification(210 /* ArrowFunction */); + context.enableEmitNotification(209 /* FunctionExpression */); + context.enableEmitNotification(252 /* FunctionDeclaration */); } } /** @@ -92400,10 +95113,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 249 /* VariableDeclaration */: + case 199 /* BindingElement */: + case 253 /* ClassDeclaration */: + case 256 /* EnumDeclaration */: + case 250 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -92485,11 +95198,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 234 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 204 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -92497,7 +95210,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 221 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -92523,15 +95236,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(275 /* JsxOpeningElement */); - context.enableEmitNotification(276 /* JsxClosingElement */); - context.enableEmitNotification(274 /* JsxSelfClosingElement */); + context.enableEmitNotification(276 /* JsxOpeningElement */); + context.enableEmitNotification(277 /* JsxClosingElement */); + context.enableEmitNotification(275 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(201 /* PropertyAccessExpression */); - context.enableSubstitution(288 /* PropertyAssignment */); + context.enableSubstitution(202 /* PropertyAccessExpression */); + context.enableSubstitution(289 /* PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -92550,9 +95263,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxOpeningElement */: + case 277 /* JsxClosingElement */: + case 275 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -92850,7 +95563,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 512 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 1024 /* ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -92873,7 +95586,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 512 /* ContainsGenerator */) { + else if (transformFlags & 1024 /* ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -92887,13 +95600,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 235 /* DoStatement */: + case 236 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 237 /* WhileStatement */: return visitWhileStatement(node); - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: return visitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -92906,30 +95619,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 209 /* FunctionExpression */: return visitFunctionExpression(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return visitAccessorDeclaration(node); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return visitVariableStatement(node); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: return visitForInStatement(node); - case 241 /* BreakStatement */: + case 242 /* BreakStatement */: return visitBreakStatement(node); - case 240 /* ContinueStatement */: + case 241 /* ContinueStatement */: return visitContinueStatement(node); - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (512 /* ContainsGenerator */ | 1048576 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (1024 /* ContainsGenerator */ | 2097152 /* ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -92944,23 +95657,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return visitBinaryExpression(node); - case 337 /* CommaListExpression */: + case 341 /* CommaListExpression */: return visitCommaListExpression(node); - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: return visitConditionalExpression(node); - case 219 /* YieldExpression */: + case 220 /* YieldExpression */: return visitYieldExpression(node); - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 203 /* CallExpression */: + case 204 /* CallExpression */: return visitCallExpression(node); - case 204 /* NewExpression */: + case 205 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -92973,9 +95686,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 208 /* FunctionExpression */: + case 209 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -93134,7 +95847,7 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 262144 /* ContainsYield */) { + if (node.transformFlags & 524288 /* ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } @@ -93183,7 +95896,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -93195,7 +95908,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -93589,35 +96302,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 230 /* Block */: + case 231 /* Block */: return transformAndEmitBlock(node); - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 234 /* IfStatement */: + case 235 /* IfStatement */: return transformAndEmitIfStatement(node); - case 235 /* DoStatement */: + case 236 /* DoStatement */: return transformAndEmitDoStatement(node); - case 236 /* WhileStatement */: + case 237 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return transformAndEmitForStatement(node); - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 240 /* ContinueStatement */: + case 241 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 241 /* BreakStatement */: + case 242 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 243 /* WithStatement */: + case 244 /* WithStatement */: return transformAndEmitWithStatement(node); - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 247 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 247 /* TryStatement */: + case 248 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -93837,7 +96550,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = factory.updateForStatement(node, variables.length > 0 ? factory.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitIterationBody(node.statement, visitor, context)); } else { node = ts.visitEachChild(node, visitor, context); @@ -94047,7 +96760,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 285 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 286 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -94060,7 +96773,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 284 /* CaseClause */) { + if (clause.kind === 285 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -94192,7 +96905,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 262144 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 524288 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -94225,10 +96938,10 @@ var ts; var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)]; if (name) { // TODO(rbuckton): Does this need to be parented? - var clone_5 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setSourceMapRange(clone_5, node); - ts.setCommentRange(clone_5, node); - return clone_5; + var clone_6 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); + ts.setSourceMapRange(clone_6, node); + ts.setCommentRange(clone_6, node); + return clone_6; } } } @@ -95221,11 +97934,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(217 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(215 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(216 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(290 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(298 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -95241,7 +97954,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 2097152 /* ContainsDynamicImport */ || + node.transformFlags & 4194304 /* ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -95553,23 +98266,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return visitExportAssignment(node); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: return visitClassDeclaration(node); - case 338 /* MergeDeclarationMarker */: + case 342 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 343 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -95578,7 +98291,7 @@ var ts; function moduleExpressionElementVisitor(node) { // This visitor does not need to descend into the tree if there is no dynamic import or destructuring assignment, // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & 2097152 /* ContainsDynamicImport */) && !(node.transformFlags & 1024 /* ContainsDestructuringAssignment */)) { + if (!(node.transformFlags & 4194304 /* ContainsDynamicImport */) && !(node.transformFlags & 2048 /* ContainsDestructuringAssignment */)) { return node; } if (ts.isImportCall(node)) { @@ -95596,24 +98309,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 290 /* SpreadAssignment */: + case 291 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -95648,7 +98361,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 4096 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 8192 /* ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -96141,7 +98854,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 233 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -96196,10 +98909,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 265 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -96412,7 +99125,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 298 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -96476,10 +99189,10 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return substituteBinaryExpression(node); - case 215 /* PostfixUnaryExpression */: - case 214 /* PrefixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -96499,9 +99212,9 @@ var ts; } return node; } - if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 298 /* SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -96576,15 +99289,21 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ - ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), factory.createNumericLiteral(1)), + var expression = node.kind === 216 /* PostfixUnaryExpression */ + ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; // Mark the node to prevent triggering this rule again. noSubstitution[ts.getNodeId(expression)] = true; - expression = factory.createParenthesizedExpression(createExportExpression(exportName, expression)); + expression = createExportExpression(exportName, expression); + } + if (node.kind === 216 /* PostfixUnaryExpression */) { + noSubstitution[ts.getNodeId(expression)] = true; + expression = node.operator === 45 /* PlusPlusToken */ + ? factory.createSubtract(expression, factory.createNumericLiteral(1)) + : factory.createAdd(expression, factory.createNumericLiteral(1)); } return expression; } @@ -96628,12 +99347,12 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(78 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(289 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(216 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(214 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(226 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(297 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(290 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(217 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(215 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(216 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(227 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(298 /* SourceFile */); // Restore state when substituting nodes in a file. 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. @@ -96653,7 +99372,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -96822,7 +99541,7 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 524288 /* ContainsAwait */ ? + var modifiers = node.transformFlags & 1048576 /* ContainsAwait */ ? factory.createModifiersFromModifierFlags(256 /* Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ @@ -96857,7 +99576,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 267 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 268 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -96947,19 +99666,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -97018,13 +99737,13 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: return visitImportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: return visitExportDeclaration(node); - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -97204,7 +99923,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 === 297 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 298 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -97268,7 +99987,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 === 232 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 233 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -97330,10 +100049,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 264 /* NamedImports */: + case 265 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -97513,43 +100232,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return visitVariableStatement(node); - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: return visitClassDeclaration(node); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return visitForStatement(node); - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: return visitForInStatement(node); - case 239 /* ForOfStatement */: + case 240 /* ForOfStatement */: return visitForOfStatement(node); - case 235 /* DoStatement */: + case 236 /* DoStatement */: return visitDoStatement(node); - case 236 /* WhileStatement */: + case 237 /* WhileStatement */: return visitWhileStatement(node); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return visitLabeledStatement(node); - case 243 /* WithStatement */: + case 244 /* WithStatement */: return visitWithStatement(node); - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: return visitSwitchStatement(node); - case 258 /* CaseBlock */: + case 259 /* CaseBlock */: return visitCaseBlock(node); - case 284 /* CaseClause */: + case 285 /* CaseClause */: return visitCaseClause(node); - case 285 /* DefaultClause */: + case 286 /* DefaultClause */: return visitDefaultClause(node); - case 247 /* TryStatement */: + case 248 /* TryStatement */: return visitTryStatement(node); - case 287 /* CatchClause */: + case 288 /* CatchClause */: return visitCatchClause(node); - case 230 /* Block */: + case 231 /* Block */: return visitBlock(node); - case 338 /* MergeDeclarationMarker */: + case 342 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 339 /* EndOfDeclarationMarker */: + case 343 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -97563,7 +100282,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = factory.updateForStatement(node, node.initializer && visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97575,7 +100294,7 @@ var ts; function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97587,7 +100306,7 @@ var ts; function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + node = factory.updateForOfStatement(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -97628,7 +100347,7 @@ var ts; * @param node The node to visit. */ function visitDoStatement(node) { - return factory.updateDoStatement(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); + return factory.updateDoStatement(node, ts.visitIterationBody(node.statement, nestedElementVisitor, context), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression)); } /** * Visits the body of a WhileStatement to hoist declarations. @@ -97636,7 +100355,7 @@ var ts; * @param node The node to visit. */ function visitWhileStatement(node) { - return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock)); + return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitIterationBody(node.statement, nestedElementVisitor, context)); } /** * Visits the body of a LabeledStatement to hoist declarations. @@ -97737,7 +100456,7 @@ var ts; else if (ts.isImportCall(node)) { return visitImportCallExpression(node); } - else if ((node.transformFlags & 1024 /* ContainsDestructuringAssignment */) || (node.transformFlags & 2097152 /* ContainsDynamicImport */)) { + else if ((node.transformFlags & 2048 /* ContainsDestructuringAssignment */) || (node.transformFlags & 4194304 /* ContainsDynamicImport */)) { return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } else { @@ -97775,7 +100494,7 @@ var ts; return ts.visitEachChild(node, destructuringAndImportCallVisitor, context); } /** - * Determines whether the target of a destructuring assigment refers to an exported symbol. + * Determines whether the target of a destructuring assignment refers to an exported symbol. * * @param node The destructuring target. */ @@ -97800,7 +100519,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 297 /* SourceFile */; + return container !== undefined && container.kind === 298 /* SourceFile */; } else { return false; @@ -97833,7 +100552,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 298 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -97883,7 +100602,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -97920,12 +100639,12 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return substituteExpressionIdentifier(node); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return substituteBinaryExpression(node); - case 214 /* PrefixUnaryExpression */: - case 215 /* PostfixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 226 /* MetaProperty */: + case 227 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -98019,14 +100738,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 215 /* PostfixUnaryExpression */ + var expression = node.kind === 216 /* PostfixUnaryExpression */ ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 215 /* PostfixUnaryExpression */) { + if (node.kind === 216 /* PostfixUnaryExpression */) { expression = node.operator === 45 /* PlusPlusToken */ ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1)) : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1)); @@ -98054,7 +100773,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 297 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 298 /* SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -98094,7 +100813,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(297 /* SourceFile */); + context.enableEmitNotification(298 /* SourceFile */); context.enableSubstitution(78 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(context, transformSourceFile); @@ -98126,12 +100845,12 @@ var ts; } function visitor(node) { switch (node.kind) { - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return visitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -98266,7 +100985,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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 253 /* 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 : @@ -98295,7 +101014,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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 253 /* 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 : @@ -98342,7 +101061,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 === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 250 /* VariableDeclaration */ || node.kind === 199 /* 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 : @@ -98351,8 +101070,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 === 163 /* PropertyDeclaration */ || node.kind === 201 /* PropertyAccessExpression */ || node.kind === 162 /* PropertySignature */ || - (node.kind === 160 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 164 /* PropertyDeclaration */ || node.kind === 202 /* PropertyAccessExpression */ || node.kind === 163 /* PropertySignature */ || + (node.kind === 161 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasSyntacticModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -98361,7 +101080,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 === 252 /* ClassDeclaration */ || node.kind === 160 /* Parameter */) { + else if (node.parent.kind === 253 /* ClassDeclaration */ || node.kind === 161 /* 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 : @@ -98386,7 +101105,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 169 /* SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.hasSyntacticModifier(node, 32 /* Static */)) { @@ -98425,26 +101144,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 170 /* ConstructSignature */: + case 171 /* 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 169 /* CallSignature */: + case 170 /* 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 171 /* IndexSignature */: + case 172 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: if (ts.hasSyntacticModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -98452,7 +101171,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 === 252 /* ClassDeclaration */) { + else if (node.parent.kind === 253 /* 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 : @@ -98466,7 +101185,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 251 /* FunctionDeclaration */: + case 252 /* 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 : @@ -98491,30 +101210,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 166 /* Constructor */: + case 167 /* 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 170 /* ConstructSignature */: - case 175 /* ConstructorType */: + case 171 /* ConstructSignature */: + case 176 /* 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 169 /* CallSignature */: + case 170 /* 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 171 /* IndexSignature */: + case 172 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -98522,7 +101241,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 === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 253 /* 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 : @@ -98535,15 +101254,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 251 /* FunctionDeclaration */: - case 174 /* FunctionType */: + case 252 /* FunctionDeclaration */: + case 175 /* 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 168 /* SetAccessor */: - case 167 /* GetAccessor */: + case 169 /* SetAccessor */: + case 168 /* 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 : @@ -98557,39 +101276,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 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 253 /* InterfaceDeclaration */: + case 254 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 190 /* MappedType */: + case 191 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 176 /* ConstructorType */: + case 171 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* CallSignature */: + case 170 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: if (ts.hasSyntacticModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 252 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 253 /* 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 174 /* FunctionType */: - case 251 /* FunctionDeclaration */: + case 175 /* FunctionType */: + case 252 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 254 /* TypeAliasDeclaration */: + case 255 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -98655,7 +101374,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 160 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 161 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -98817,11 +101536,14 @@ var ts; } } function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) { - var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); + var _a; + var primaryDeclaration = (_a = parentSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; }); - for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { - var augmentations = augmentingDeclarations_1[_i]; - context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + if (augmentingDeclarations) { + for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { + var augmentations = augmentingDeclarations_1[_i]; + context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + } } } function transformDeclarationsForJS(sourceFile, bundled) { @@ -98837,10 +101559,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 297 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 298 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 298 /* Bundle */) { + if (node.kind === 299 /* Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -98870,7 +101592,7 @@ var ts; 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 === 300 /* InputFiles */) { + if (prepend.kind === 301 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -98962,7 +101684,7 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { - var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, + var specifier = ts.moduleSpecifiers.getModuleSpecifier(options, currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, /*preferences*/ undefined); if (!ts.pathIsRelative(specifier)) { // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration @@ -99011,7 +101733,7 @@ var ts; return name; } else { - if (name.kind === 197 /* ArrayBindingPattern */) { + if (name.kind === 198 /* ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -99019,7 +101741,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 222 /* OmittedExpression */) { + if (elem.kind === 223 /* OmittedExpression */) { return elem; } return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -99057,7 +101779,7 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 160 /* Parameter */ && + var shouldUseResolverType = node.kind === 161 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -99066,7 +101788,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(128 /* AnyKeyword */); } - if (node.kind === 168 /* SetAccessor */) { + if (node.kind === 169 /* SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) return factory.createKeywordTypeNode(128 /* AnyKeyword */); @@ -99077,12 +101799,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 249 /* VariableDeclaration */ || node.kind === 198 /* BindingElement */) { + if (node.kind === 250 /* VariableDeclaration */ || node.kind === 199 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 160 /* Parameter */ - || node.kind === 163 /* PropertyDeclaration */ - || node.kind === 162 /* PropertySignature */) { + if (node.kind === 161 /* Parameter */ + || node.kind === 164 /* PropertyDeclaration */ + || node.kind === 163 /* 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)); @@ -99099,20 +101821,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: + case 252 /* FunctionDeclaration */: + case 257 /* ModuleDeclaration */: + case 254 /* InterfaceDeclaration */: + case 253 /* ClassDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 256 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 261 /* ImportEqualsDeclaration */: + case 262 /* ImportDeclaration */: + case 268 /* ExportDeclaration */: + case 267 /* ExportAssignment */: return false; } return false; @@ -99193,7 +101915,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 /* ModuleDeclaration */ && parent.kind !== 195 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 257 /* ModuleDeclaration */ && parent.kind !== 196 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -99213,7 +101935,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 272 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 273 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, @@ -99240,7 +101962,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 264 /* 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; @@ -99335,7 +102057,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 /* TypeLiteral */ || input.kind === 190 /* MappedType */) && input.parent.kind !== 254 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 178 /* TypeLiteral */ || input.kind === 191 /* MappedType */) && input.parent.kind !== 255 /* 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 */)) { @@ -99356,21 +102078,21 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 223 /* ExpressionWithTypeArguments */: { + case 224 /* 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 173 /* TypeReference */: { + case 174 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 170 /* ConstructSignature */: + case 171 /* ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 166 /* Constructor */: { + case 167 /* Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( /*decorators*/ undefined, @@ -99378,7 +102100,7 @@ var ts; /*body*/ undefined); return cleanup(ctor); } - case 165 /* MethodDeclaration */: { + case 166 /* MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99388,7 +102110,7 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 167 /* GetAccessor */: { + case 168 /* GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99397,7 +102119,7 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 168 /* SetAccessor */: { + case 169 /* SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -99405,31 +102127,31 @@ var ts; /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), /*body*/ undefined)); } - case 163 /* PropertyDeclaration */: + case 164 /* 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 162 /* PropertySignature */: + case 163 /* 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 164 /* MethodSignature */: { + case 165 /* 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 169 /* CallSignature */: { + case 170 /* CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 171 /* IndexSignature */: { + case 172 /* IndexSignature */: { return cleanup(factory.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128 /* AnyKeyword */))); } - case 249 /* VariableDeclaration */: { + case 250 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -99437,13 +102159,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 159 /* TypeParameter */: { + case 160 /* 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 184 /* ConditionalType */: { + case 185 /* 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); @@ -99455,13 +102177,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 174 /* FunctionType */: { + case 175 /* FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 175 /* ConstructorType */: { + case 176 /* ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 195 /* ImportType */: { + case 196 /* 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)); @@ -99493,7 +102215,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 165 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 166 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -99503,7 +102225,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 267 /* ExportDeclaration */: { + case 268 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -99513,7 +102235,7 @@ var ts; return factory.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 266 /* ExportAssignment */: { + case 267 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -99547,17 +102269,17 @@ var ts; // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (11263 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (27647 /* All */ ^ 1 /* Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { if (shouldStripInternal(input)) return; switch (input.kind) { - case 260 /* ImportEqualsDeclaration */: { + case 261 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 261 /* ImportDeclaration */: { + case 262 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -99578,14 +102300,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 254 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 255 /* 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 253 /* InterfaceDeclaration */: { + case 254 /* 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 251 /* FunctionDeclaration */: { + case 252 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -99600,7 +102322,7 @@ var ts; fakespace_1.symbol = props[0].parent; var exportMappings_1 = []; var declarations = ts.mapDefined(props, function (p) { - if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { + if (!p.valueDeclaration || !ts.isPropertyAccessExpression(p.valueDeclaration)) { return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); @@ -99652,10 +102374,10 @@ var ts; return clean; } } - case 256 /* ModuleDeclaration */: { + case 257 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 257 /* ModuleBlock */) { + if (inner && inner.kind === 258 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; @@ -99698,7 +102420,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 252 /* ClassDeclaration */: { + case 253 /* ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -99708,7 +102430,7 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); if (param.name.kind === 78 /* Identifier */) { @@ -99783,10 +102505,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 232 /* VariableStatement */: { + case 233 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 255 /* EnumDeclaration */: { + case 256 /* 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; @@ -99805,7 +102527,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 256 /* ModuleDeclaration */) { + if (input.kind === 257 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -99828,7 +102550,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 222 /* OmittedExpression */) { + if (e.kind === 223 /* OmittedExpression */) { return; } if (e.name) { @@ -99876,9 +102598,9 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 11263 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files + 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 === 297 /* SourceFile */; + var parentIsFile = node.parent.kind === 298 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -99907,7 +102629,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 253 /* InterfaceDeclaration */) { + if (node.kind === 254 /* InterfaceDeclaration */) { return true; } return false; @@ -99917,7 +102639,7 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 11263 /* All */ ^ 4 /* Public */; } + if (modifierMask === void 0) { modifierMask = 27647 /* All */ ^ 4 /* Public */; } if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { @@ -99932,7 +102654,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 167 /* GetAccessor */ + return accessor.kind === 168 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -99941,52 +102663,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 160 /* Parameter */: - case 249 /* VariableDeclaration */: + case 161 /* Parameter */: + case 250 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 253 /* InterfaceDeclaration */: - case 252 /* ClassDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 232 /* VariableStatement */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 266 /* ExportAssignment */: + case 252 /* FunctionDeclaration */: + case 257 /* ModuleDeclaration */: + case 261 /* ImportEqualsDeclaration */: + case 254 /* InterfaceDeclaration */: + case 253 /* ClassDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 256 /* EnumDeclaration */: + case 233 /* VariableStatement */: + case 262 /* ImportDeclaration */: + case 268 /* ExportDeclaration */: + case 267 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 170 /* ConstructSignature */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 171 /* IndexSignature */: - case 249 /* VariableDeclaration */: - case 159 /* TypeParameter */: - case 223 /* ExpressionWithTypeArguments */: - case 173 /* TypeReference */: - case 184 /* ConditionalType */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 195 /* ImportType */: + case 171 /* ConstructSignature */: + case 167 /* Constructor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 165 /* MethodSignature */: + case 170 /* CallSignature */: + case 172 /* IndexSignature */: + case 250 /* VariableDeclaration */: + case 160 /* TypeParameter */: + case 224 /* ExpressionWithTypeArguments */: + case 174 /* TypeReference */: + case 185 /* ConditionalType */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: + case 196 /* ImportType */: return true; } return false; @@ -100042,6 +102764,9 @@ var ts; if (languageVersion < 99 /* ESNext */) { transformers.push(ts.transformESNext); } + if (languageVersion < 8 /* ES2021 */) { + transformers.push(ts.transformES2021); + } if (languageVersion < 7 /* ES2020 */) { transformers.push(ts.transformES2020); } @@ -100118,7 +102843,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(341 /* Count */); + var enabledSyntaxKindFeatures = new Array(345 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; @@ -100129,6 +102854,9 @@ var ts; var lexicalEnvironmentFlagsStack = []; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; + var blockScopedVariableDeclarationsStack = []; + var blockScopeStackOffset = 0; + var blockScopedVariableDeclarations; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; @@ -100151,6 +102879,9 @@ var ts; hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, addInitializationStatement: addInitializationStatement, + startBlockScope: startBlockScope, + endBlockScope: endBlockScope, + addBlockScopedVariable: addBlockScopedVariable, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, enableSubstitution: enableSubstitution, @@ -100194,7 +102925,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 === 297 /* 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 === 298 /* 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(); } @@ -100411,6 +103142,38 @@ var ts; function getLexicalEnvironmentFlags() { return lexicalEnvironmentFlags; } + /** + * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. + */ + function startBlockScope() { + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; + blockScopeStackOffset++; + blockScopedVariableDeclarations = undefined; + } + /** + * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. + */ + function endBlockScope() { + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + var statements = ts.some(blockScopedVariableDeclarations) ? + [ + factory.createVariableStatement( + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + ] : undefined; + blockScopeStackOffset--; + blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; + if (blockScopeStackOffset === 0) { + blockScopedVariableDeclarationsStack = []; + } + return statements; + } + function addBlockScopedVariable(name) { + ts.Debug.assert(blockScopeStackOffset > 0, "Cannot add a block scoped variable outside of an iteration body."); + (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); + } function requestEmitHelper(helper) { ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); @@ -100452,35 +103215,37 @@ var ts; } ts.transformNodes = transformNodes; ts.nullTransformationContext = { - get factory() { return ts.factory; }, - enableEmitNotification: ts.noop, - enableSubstitution: ts.noop, - endLexicalEnvironment: ts.returnUndefined, + factory: ts.factory, getCompilerOptions: function () { return ({}); }, - getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, + getEmitHost: ts.notImplemented, getEmitHelperFactory: ts.notImplemented, + startLexicalEnvironment: ts.noop, + resumeLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop, + endLexicalEnvironment: ts.returnUndefined, setLexicalEnvironmentFlags: ts.noop, getLexicalEnvironmentFlags: function () { return 0; }, - hoistFunctionDeclaration: ts.noop, hoistVariableDeclaration: ts.noop, + hoistFunctionDeclaration: ts.noop, addInitializationStatement: ts.noop, - isEmitNotificationEnabled: ts.notImplemented, - isSubstitutionEnabled: ts.notImplemented, - onEmitNode: ts.noop, - onSubstituteNode: ts.notImplemented, - readEmitHelpers: ts.notImplemented, + startBlockScope: ts.noop, + endBlockScope: ts.returnUndefined, + addBlockScopedVariable: ts.noop, requestEmitHelper: ts.noop, - resumeLexicalEnvironment: ts.noop, - startLexicalEnvironment: ts.noop, - suspendLexicalEnvironment: ts.noop, + readEmitHelpers: ts.notImplemented, + enableSubstitution: ts.noop, + enableEmitNotification: ts.noop, + isSubstitutionEnabled: ts.notImplemented, + isEmitNotificationEnabled: ts.notImplemented, + onSubstituteNode: noEmitSubstitution, + onEmitNode: noEmitNotification, addDiagnostic: ts.noop, }; })(ts || (ts = {})); var ts; (function (ts) { var brackets = createBracketsMap(); - var syntheticParent = { pos: -1, end: -1 }; /*@internal*/ function isBuildInfoFile(file) { return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); @@ -100566,7 +103331,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 298 /* Bundle */) { + if (sourceFile.kind === 299 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -100927,13 +103692,13 @@ var ts; if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { - sourceMap: compilerOptions.declarationMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 297 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 298 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -100956,8 +103721,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 298 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 297 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 299 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 298 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -100998,7 +103763,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 297 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 298 /* 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 @@ -101057,7 +103822,7 @@ var ts; ts.emitFiles = emitFiles; /*@internal*/ function getBuildInfoText(buildInfo) { - return JSON.stringify(buildInfo, undefined, 2); + return JSON.stringify(buildInfo); } ts.getBuildInfoText = getBuildInfoText; /*@internal*/ @@ -101238,7 +104003,7 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; + var hasGlobalName = handlers.hasGlobalName, _a = handlers.onEmitNode, onEmitNode = _a === void 0 ? ts.noEmitNotification : _a, isEmitNotificationEnabled = handlers.isEmitNotificationEnabled, _b = handlers.substituteNode, substituteNode = _b === void 0 ? ts.noEmitSubstitution : _b, onBeforeEmitNode = handlers.onBeforeEmitNode, onAfterEmitNode = handlers.onAfterEmitNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray, onBeforeEmitToken = handlers.onBeforeEmitToken, onAfterEmitToken = handlers.onAfterEmitToken; var extendedDiagnostics = !!printerOptions.extendedDiagnostics; var newLine = ts.getNewLineCharacter(printerOptions); var moduleKind = ts.getEmitModuleKind(printerOptions); @@ -101277,9 +104042,11 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; - var lastNode; var lastSubstitution; + var currentParenthesizerRule; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; + var parenthesizer = ts.factory.parenthesizer; + var emitBinaryExpression = createEmitBinaryExpression(); reset(); return { // public API @@ -101307,9 +104074,9 @@ var ts; break; } switch (node.kind) { - case 297 /* SourceFile */: return printFile(node); - case 298 /* Bundle */: return printBundle(node); - case 299 /* UnparsedSource */: return printUnparsedSource(node); + case 298 /* SourceFile */: return printFile(node); + case 299 /* Bundle */: return printBundle(node); + case 300 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -101343,7 +104110,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - emitList(syntheticParent, nodes, format); + emitList(/*parentNode*/ undefined, nodes, format); reset(); writer = previousWriter; } @@ -101478,7 +104245,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - pipelineEmit(hint, node); + pipelineEmit(hint, node, /*parenthesizerRule*/ undefined); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -101506,51 +104273,54 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; - lastNode = undefined; - lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile)); } - function emit(node) { + function emit(node, parenthesizerRule) { if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var substitute = pipelineEmit(4 /* Unspecified */, node); + pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); - return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - return pipelineEmit(2 /* IdentifierName */, node); + pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); } - function emitExpression(node) { + function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - return pipelineEmit(1 /* Expression */, node); + pipelineEmit(1 /* Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - return pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); } - function pipelineEmit(emitHint, node) { - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - var savedPreserveSourceNewlines = preserveSourceNewlines; - lastNode = node; - lastSubstitution = undefined; - if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + function beforeEmitNode(node) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } + } + function afterEmitNode(savedPreserveSourceNewlines) { + preserveSourceNewlines = savedPreserveSourceNewlines; + } + function pipelineEmit(emitHint, node, parenthesizerRule) { + currentParenthesizerRule = parenthesizerRule; var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); pipelinePhase(emitHint, node); - ts.Debug.assert(lastNode === node); - var substitute = lastSubstitution; - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - preserveSourceNewlines = savedPreserveSourceNewlines; - return substitute || node; + currentParenthesizerRule = undefined; + } + function shouldEmitComments(node) { + return !commentsDisabled && !ts.isSourceFile(node); + } + function shouldEmitSourceMaps(node) { + return !sourceMapsDisabled && + !ts.isSourceFile(node) && + !ts.isInJsonFile(node) && + !ts.isUnparsedSource(node) && + !ts.isUnparsedPrepend(node); } function getPipelinePhase(phase, emitHint, node) { switch (phase) { @@ -101560,18 +104330,21 @@ var ts; } // falls through case 1 /* Substitution */: - if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) { + if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { + if (currentParenthesizerRule) { + lastSubstitution = currentParenthesizerRule(lastSubstitution); + } return pipelineEmitWithSubstitution; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 297 /* SourceFile */) { + if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 297 /* SourceFile */ && !ts.isInJsonFile(node)) { - return pipelineEmitWithSourceMap; + if (shouldEmitSourceMaps(node)) { + return pipelineEmitWithSourceMaps; } // falls through case 4 /* Emit */: @@ -101584,13 +104357,25 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); - ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (preserveSourceNewlines) { + var savedPreserveSourceNewlines = preserveSourceNewlines; + beforeEmitNode(node); + pipelineEmitWithHintWorker(hint, node); + afterEmitNode(savedPreserveSourceNewlines); + } + else { + pipelineEmitWithHintWorker(hint, node); + } + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + // clear the parenthesizer rule as we ascend + currentParenthesizerRule = undefined; + } + function pipelineEmitWithHintWorker(hint, node) { if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -101604,24 +104389,12 @@ var ts; return emitEmptyStatement(/*isEmbeddedStatement*/ true); } if (hint === 4 /* Unspecified */) { - if (ts.isKeyword(node.kind)) - return writeTokenNode(node, writeKeyword); switch (node.kind) { // Pseudo-literals case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); - case 299 /* UnparsedSource */: - case 293 /* UnparsedPrepend */: - return emitUnparsedSourceOrPrepend(node); - case 292 /* UnparsedPrologue */: - return writeUnparsedNode(node); - case 294 /* UnparsedText */: - case 295 /* UnparsedInternalText */: - return emitUnparsedTextLike(node); - case 296 /* UnparsedSyntheticReference */: - return emitUnparsedSyntheticReference(node); // Identifiers case 78 /* Identifier */: return emitIdentifier(node); @@ -101630,282 +104403,323 @@ var ts; return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: return emitQualifiedName(node); - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 159 /* TypeParameter */: + case 160 /* TypeParameter */: return emitTypeParameter(node); - case 160 /* Parameter */: + case 161 /* Parameter */: return emitParameter(node); - case 161 /* Decorator */: + case 162 /* Decorator */: return emitDecorator(node); // Type members - case 162 /* PropertySignature */: + case 163 /* PropertySignature */: return emitPropertySignature(node); - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 164 /* MethodSignature */: + case 165 /* MethodSignature */: return emitMethodSignature(node); - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 166 /* Constructor */: + case 167 /* Constructor */: return emitConstructor(node); - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return emitAccessorDeclaration(node); - case 169 /* CallSignature */: + case 170 /* CallSignature */: return emitCallSignature(node); - case 170 /* ConstructSignature */: + case 171 /* ConstructSignature */: return emitConstructSignature(node); - case 171 /* IndexSignature */: + case 172 /* IndexSignature */: return emitIndexSignature(node); - case 194 /* TemplateLiteralTypeSpan */: - return emitTemplateTypeSpan(node); // Types - case 172 /* TypePredicate */: + case 173 /* TypePredicate */: return emitTypePredicate(node); - case 173 /* TypeReference */: + case 174 /* TypeReference */: return emitTypeReference(node); - case 174 /* FunctionType */: + case 175 /* FunctionType */: return emitFunctionType(node); - case 308 /* JSDocFunctionType */: - return emitJSDocFunctionType(node); - case 175 /* ConstructorType */: + case 176 /* ConstructorType */: return emitConstructorType(node); - case 176 /* TypeQuery */: + case 177 /* TypeQuery */: return emitTypeQuery(node); - case 177 /* TypeLiteral */: + case 178 /* TypeLiteral */: return emitTypeLiteral(node); - case 178 /* ArrayType */: + case 179 /* ArrayType */: return emitArrayType(node); - case 179 /* TupleType */: + case 180 /* TupleType */: return emitTupleType(node); - case 180 /* OptionalType */: + case 181 /* OptionalType */: return emitOptionalType(node); - case 182 /* UnionType */: + // SyntaxKind.RestType is handled below + case 183 /* UnionType */: return emitUnionType(node); - case 183 /* IntersectionType */: + case 184 /* IntersectionType */: return emitIntersectionType(node); - case 184 /* ConditionalType */: + case 185 /* ConditionalType */: return emitConditionalType(node); - case 185 /* InferType */: + case 186 /* InferType */: return emitInferType(node); - case 186 /* ParenthesizedType */: + case 187 /* ParenthesizedType */: return emitParenthesizedType(node); - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 187 /* ThisType */: + case 188 /* ThisType */: return emitThisType(); - case 188 /* TypeOperator */: + case 189 /* TypeOperator */: return emitTypeOperator(node); - case 189 /* IndexedAccessType */: + case 190 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 190 /* MappedType */: + case 191 /* MappedType */: return emitMappedType(node); - case 191 /* LiteralType */: + case 192 /* LiteralType */: return emitLiteralType(node); - case 193 /* TemplateLiteralType */: + case 193 /* NamedTupleMember */: + return emitNamedTupleMember(node); + case 194 /* TemplateLiteralType */: return emitTemplateType(node); - case 195 /* ImportType */: + case 195 /* TemplateLiteralTypeSpan */: + return emitTemplateTypeSpan(node); + case 196 /* ImportType */: return emitImportTypeNode(node); - case 303 /* JSDocAllType */: - writePunctuation("*"); - return; - case 304 /* JSDocUnknownType */: - writePunctuation("?"); - return; - case 305 /* JSDocNullableType */: - return emitJSDocNullableType(node); - case 306 /* JSDocNonNullableType */: - return emitJSDocNonNullableType(node); - case 307 /* JSDocOptionalType */: - return emitJSDocOptionalType(node); - case 181 /* RestType */: - case 309 /* JSDocVariadicType */: - return emitRestOrJSDocVariadicType(node); - case 192 /* NamedTupleMember */: - return emitNamedTupleMember(node); // Binding patterns - case 196 /* ObjectBindingPattern */: + case 197 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 197 /* ArrayBindingPattern */: + case 198 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 198 /* BindingElement */: + case 199 /* BindingElement */: return emitBindingElement(node); // Misc - case 228 /* TemplateSpan */: + case 229 /* TemplateSpan */: return emitTemplateSpan(node); - case 229 /* SemicolonClassElement */: + case 230 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 230 /* Block */: + case 231 /* Block */: return emitBlock(node); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return emitVariableStatement(node); - case 231 /* EmptyStatement */: + case 232 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: return emitExpressionStatement(node); - case 234 /* IfStatement */: + case 235 /* IfStatement */: return emitIfStatement(node); - case 235 /* DoStatement */: + case 236 /* DoStatement */: return emitDoStatement(node); - case 236 /* WhileStatement */: + case 237 /* WhileStatement */: return emitWhileStatement(node); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return emitForStatement(node); - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: return emitForInStatement(node); - case 239 /* ForOfStatement */: + case 240 /* ForOfStatement */: return emitForOfStatement(node); - case 240 /* ContinueStatement */: + case 241 /* ContinueStatement */: return emitContinueStatement(node); - case 241 /* BreakStatement */: + case 242 /* BreakStatement */: return emitBreakStatement(node); - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: return emitReturnStatement(node); - case 243 /* WithStatement */: + case 244 /* WithStatement */: return emitWithStatement(node); - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: return emitSwitchStatement(node); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: return emitLabeledStatement(node); - case 246 /* ThrowStatement */: + case 247 /* ThrowStatement */: return emitThrowStatement(node); - case 247 /* TryStatement */: + case 248 /* TryStatement */: return emitTryStatement(node); - case 248 /* DebuggerStatement */: + case 249 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 250 /* VariableDeclarationList */: + case 251 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: return emitClassDeclaration(node); - case 253 /* InterfaceDeclaration */: + case 254 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 254 /* TypeAliasDeclaration */: + case 255 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 257 /* ModuleBlock */: + case 258 /* ModuleBlock */: return emitModuleBlock(node); - case 258 /* CaseBlock */: + case 259 /* CaseBlock */: return emitCaseBlock(node); - case 259 /* NamespaceExportDeclaration */: + case 260 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: return emitImportDeclaration(node); - case 262 /* ImportClause */: + case 263 /* ImportClause */: return emitImportClause(node); - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: return emitNamespaceImport(node); - case 269 /* NamespaceExport */: + case 270 /* NamespaceExport */: return emitNamespaceExport(node); - case 264 /* NamedImports */: + case 265 /* NamedImports */: return emitNamedImports(node); - case 265 /* ImportSpecifier */: + case 266 /* ImportSpecifier */: return emitImportSpecifier(node); - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return emitExportAssignment(node); - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: return emitExportDeclaration(node); - case 268 /* NamedExports */: + case 269 /* NamedExports */: return emitNamedExports(node); - case 270 /* ExportSpecifier */: + case 271 /* ExportSpecifier */: return emitExportSpecifier(node); - case 271 /* MissingDeclaration */: + case 272 /* MissingDeclaration */: return; // Module references - case 272 /* ExternalModuleReference */: + case 273 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: + case 276 /* JsxOpeningElement */: + case 279 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 276 /* JsxClosingElement */: - case 279 /* JsxClosingFragment */: + case 277 /* JsxClosingElement */: + case 280 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 280 /* JsxAttribute */: + case 281 /* JsxAttribute */: return emitJsxAttribute(node); - case 281 /* JsxAttributes */: + case 282 /* JsxAttributes */: return emitJsxAttributes(node); - case 282 /* JsxSpreadAttribute */: + case 283 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 284 /* CaseClause */: + case 285 /* CaseClause */: return emitCaseClause(node); - case 285 /* DefaultClause */: + case 286 /* DefaultClause */: return emitDefaultClause(node); - case 286 /* HeritageClause */: + case 287 /* HeritageClause */: return emitHeritageClause(node); - case 287 /* CatchClause */: + case 288 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 290 /* SpreadAssignment */: + case 291 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 291 /* EnumMember */: + case 292 /* EnumMember */: return emitEnumMember(node); + // Unparsed + case 293 /* UnparsedPrologue */: + return writeUnparsedNode(node); + case 300 /* UnparsedSource */: + case 294 /* UnparsedPrepend */: + return emitUnparsedSourceOrPrepend(node); + case 295 /* UnparsedText */: + case 296 /* UnparsedInternalText */: + return emitUnparsedTextLike(node); + case 297 /* UnparsedSyntheticReference */: + return emitUnparsedSyntheticReference(node); + // Top-level nodes + case 298 /* SourceFile */: + return emitSourceFile(node); + case 299 /* Bundle */: + return ts.Debug.fail("Bundles should be printed using printBundle"); + // SyntaxKind.UnparsedSource (handled above) + case 301 /* InputFiles */: + return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 302 /* JSDocTypeExpression */: + return emitJSDocTypeExpression(node); + case 303 /* JSDocNameReference */: + return emitJSDocNameReference(node); + case 304 /* JSDocAllType */: + return writePunctuation("*"); + case 305 /* JSDocUnknownType */: + return writePunctuation("?"); + case 306 /* JSDocNullableType */: + return emitJSDocNullableType(node); + case 307 /* JSDocNonNullableType */: + return emitJSDocNonNullableType(node); + case 308 /* JSDocOptionalType */: + return emitJSDocOptionalType(node); + case 309 /* JSDocFunctionType */: + return emitJSDocFunctionType(node); + case 182 /* RestType */: + case 310 /* JSDocVariadicType */: + return emitRestOrJSDocVariadicType(node); + case 311 /* JSDocNamepathType */: + return; + case 312 /* JSDocComment */: + return emitJSDoc(node); + case 314 /* JSDocTypeLiteral */: + return emitJSDocTypeLiteral(node); + case 315 /* JSDocSignature */: + return emitJSDocSignature(node); + case 317 /* JSDocTag */: + case 322 /* JSDocClassTag */: + return emitJSDocSimpleTag(node); + case 318 /* JSDocAugmentsTag */: + case 319 /* JSDocImplementsTag */: + return emitJSDocHeritageTag(node); + case 320 /* JSDocAuthorTag */: + case 321 /* JSDocDeprecatedTag */: + return; + // SyntaxKind.JSDocClassTag (see JSDocTag, above) + case 323 /* JSDocPublicTag */: + case 324 /* JSDocPrivateTag */: + case 325 /* JSDocProtectedTag */: + case 326 /* JSDocReadonlyTag */: + case 327 /* JSDocOverrideTag */: + return; + case 328 /* JSDocCallbackTag */: + return emitJSDocCallbackTag(node); + // SyntaxKind.JSDocEnumTag (see below) + case 330 /* JSDocParameterTag */: + case 337 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 328 /* JSDocThisTag */: - case 325 /* JSDocEnumTag */: + case 329 /* JSDocEnumTag */: + case 331 /* JSDocReturnTag */: + case 332 /* JSDocThisTag */: + case 333 /* JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 316 /* JSDocImplementsTag */: - case 315 /* JSDocAugmentsTag */: - return emitJSDocHeritageTag(node); - case 330 /* JSDocTemplateTag */: + case 334 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 331 /* JSDocTypedefTag */: + case 335 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 324 /* JSDocCallbackTag */: - return emitJSDocCallbackTag(node); - case 313 /* JSDocSignature */: - return emitJSDocSignature(node); - case 312 /* JSDocTypeLiteral */: - return emitJSDocTypeLiteral(node); - case 319 /* JSDocClassTag */: - case 314 /* JSDocTag */: - return emitJSDocSimpleTag(node); - case 332 /* JSDocSeeTag */: + case 336 /* JSDocSeeTag */: return emitJSDocSeeTag(node); - case 302 /* JSDocNameReference */: - return emitJSDocNameReference(node); - case 311 /* JSDocComment */: - return emitJSDoc(node); - // Transformation nodes (ignored) + // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) + // Transformation nodes + case 339 /* NotEmittedStatement */: + case 343 /* EndOfDeclarationMarker */: + case 342 /* MergeDeclarationMarker */: + return; } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - lastSubstitution = node = substituteNode(hint, node); + var substitute = substituteNode(hint, node) || node; + if (substitute !== node) { + node = substitute; + if (currentParenthesizerRule) { + node = currentParenthesizerRule(node); + } + } } } - else if (ts.isToken(node)) { - return writeTokenNode(node, writePunctuation); - } } if (hint === 1 /* Expression */) { switch (node.kind) { @@ -101920,84 +104734,92 @@ var ts; // Identifiers case 78 /* Identifier */: return emitIdentifier(node); - // Reserved words - case 94 /* FalseKeyword */: - case 103 /* NullKeyword */: - case 105 /* SuperKeyword */: - case 109 /* TrueKeyword */: - case 107 /* ThisKeyword */: - case 99 /* ImportKeyword */: - writeTokenNode(node, writeKeyword); - return; // Expressions - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 203 /* CallExpression */: + case 204 /* CallExpression */: return emitCallExpression(node); - case 204 /* NewExpression */: + case 205 /* NewExpression */: return emitNewExpression(node); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 206 /* TypeAssertionExpression */: + case 207 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 208 /* FunctionExpression */: + case 209 /* FunctionExpression */: return emitFunctionExpression(node); - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return emitArrowFunction(node); - case 210 /* DeleteExpression */: + case 211 /* DeleteExpression */: return emitDeleteExpression(node); - case 211 /* TypeOfExpression */: + case 212 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 212 /* VoidExpression */: + case 213 /* VoidExpression */: return emitVoidExpression(node); - case 213 /* AwaitExpression */: + case 214 /* AwaitExpression */: return emitAwaitExpression(node); - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return emitBinaryExpression(node); - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: return emitConditionalExpression(node); - case 218 /* TemplateExpression */: + case 219 /* TemplateExpression */: return emitTemplateExpression(node); - case 219 /* YieldExpression */: + case 220 /* YieldExpression */: return emitYieldExpression(node); - case 220 /* SpreadElement */: - return emitSpreadExpression(node); - case 221 /* ClassExpression */: + case 221 /* SpreadElement */: + return emitSpreadElement(node); + case 222 /* ClassExpression */: return emitClassExpression(node); - case 222 /* OmittedExpression */: + case 223 /* OmittedExpression */: return; - case 224 /* AsExpression */: + case 225 /* AsExpression */: return emitAsExpression(node); - case 225 /* NonNullExpression */: + case 226 /* NonNullExpression */: return emitNonNullExpression(node); - case 226 /* MetaProperty */: + case 227 /* MetaProperty */: return emitMetaProperty(node); + case 228 /* SyntheticExpression */: + return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 273 /* JsxElement */: + case 274 /* JsxElement */: return emitJsxElement(node); - case 274 /* JsxSelfClosingElement */: + case 275 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 277 /* JsxFragment */: + case 278 /* JsxFragment */: return emitJsxFragment(node); + // Synthesized list + case 338 /* SyntaxList */: + return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 336 /* PartiallyEmittedExpression */: + case 339 /* NotEmittedStatement */: + return; + case 340 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 337 /* CommaListExpression */: + case 341 /* CommaListExpression */: return emitCommaList(node); + case 342 /* MergeDeclarationMarker */: + case 343 /* EndOfDeclarationMarker */: + return; + case 344 /* SyntheticReferenceExpression */: + return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } + if (ts.isKeyword(node.kind)) + return writeTokenNode(node, writeKeyword); + if (ts.isTokenKind(node.kind)) + return writeTokenNode(node, writePunctuation); + ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); } function emitMappedTypeParameter(node) { emit(node.name); @@ -102007,10 +104829,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); - pipelinePhase(hint, lastSubstitution); - ts.Debug.assert(lastNode === node || lastSubstitution === node); + ts.Debug.assertIsDefined(lastSubstitution); + node = lastSubstitution; + lastSubstitution = undefined; + pipelinePhase(hint, node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -102036,7 +104859,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 298 /* Bundle */ ? node : undefined; + var bundle = node.kind === 299 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -102136,7 +104959,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 295 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -102182,7 +105005,7 @@ var ts; } function emitComputedPropertyName(node) { writePunctuation("["); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfComputedPropertyName); writePunctuation("]"); } // @@ -102209,18 +105032,18 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 308 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 309 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { emitTypeAnnotation(node.type); } // The comment position has to fallback to any present node within the parameterdeclaration because as it turns out, the parser can make parameter declarations with _just_ an initializer. - emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitDecorator(decorator) { writePunctuation("@"); - emitExpression(decorator.expression); + emitExpression(decorator.expression, parenthesizer.parenthesizeLeftSideOfAccess); } // // Type members @@ -102271,7 +105094,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 167 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 168 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -102385,7 +105208,7 @@ var ts; writePunctuation("}"); } function emitArrayType(node) { - emit(node.elementType); + emit(node.elementType, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("["); writePunctuation("]"); } @@ -102408,21 +105231,21 @@ var ts; emit(node.type); } function emitOptionalType(node) { - emit(node.type); + emit(node.type, parenthesizer.parenthesizeElementTypeOfArrayType); writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */); + emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */); + emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeMemberOfElementType); } function emitConditionalType(node) { - emit(node.checkType); + emit(node.checkType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writeKeyword("extends"); writeSpace(); - emit(node.extendsType); + emit(node.extendsType, parenthesizer.parenthesizeMemberOfConditionalType); writeSpace(); writePunctuation("?"); writeSpace(); @@ -102448,10 +105271,10 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - emit(node.type); + emit(node.type, parenthesizer.parenthesizeMemberOfElementType); } function emitIndexedAccessType(node) { - emit(node.objectType); + emit(node.objectType, parenthesizer.parenthesizeMemberOfElementType); writePunctuation("["); emit(node.indexType); writePunctuation("]"); @@ -102544,7 +105367,7 @@ var ts; writeSpace(); } emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // Expressions @@ -102552,7 +105375,7 @@ var ts; function emitArrayLiteralExpression(node) { var elements = node.elements; var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine); + emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); @@ -102568,13 +105391,13 @@ var ts; } } function emitPropertyAccessExpression(node) { - var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && - mayNeedDotDotForPropertyAccess(expression) && + mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { @@ -102610,27 +105433,27 @@ var ts; } } function emitElementAccessExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); + emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { emitTokenWithComment(102 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */); + emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - emitExpression(node.tag); + emitExpression(node.tag, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); writeSpace(); emitExpression(node.template); @@ -102639,12 +105462,12 @@ var ts; writePunctuation("<"); emit(node.type); writePunctuation(">"); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); @@ -102668,29 +105491,29 @@ var ts; function emitDeleteExpression(node) { emitTokenWithComment(88 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { emitTokenWithComment(111 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { emitTokenWithComment(113 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { emitTokenWithComment(130 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitPrefixUnaryExpression(node) { writeTokenText(node.operator, writeOperator); if (shouldEmitWhitespaceBeforeOperand(node)) { writeSpace(); } - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPrefixUnary); } function shouldEmitWhitespaceBeforeOperand(node) { // In some cases, we need to emit a space between the operator and the operand. One obvious case @@ -102706,84 +105529,101 @@ 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 === 214 /* PrefixUnaryExpression */ + return operand.kind === 215 /* 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 */))); } function emitPostfixUnaryExpression(node) { - emitExpression(node.operand); + emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); writeTokenText(node.operator, writeOperator); } - var EmitBinaryExpressionState; - (function (EmitBinaryExpressionState) { - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitLeft"] = 0] = "EmitLeft"; - EmitBinaryExpressionState[EmitBinaryExpressionState["EmitRight"] = 1] = "EmitRight"; - EmitBinaryExpressionState[EmitBinaryExpressionState["FinishEmit"] = 2] = "FinishEmit"; - })(EmitBinaryExpressionState || (EmitBinaryExpressionState = {})); - /** - * emitBinaryExpression includes an embedded work stack to attempt to handle as many nested binary expressions - * as possible without creating any additional stack frames. This can only be done when the emit pipeline does - * not require notification/substitution/comment/sourcemap decorations. - */ - function emitBinaryExpression(node) { - var nodeStack = [node]; - var stateStack = [0 /* EmitLeft */]; - var stackIndex = 0; - while (stackIndex >= 0) { - node = nodeStack[stackIndex]; - switch (stateStack[stackIndex]) { - case 0 /* EmitLeft */: { - maybePipelineEmitExpression(node.left); - break; - } - case 1 /* EmitRight */: { - var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - writeLinesAndIndent(linesBeforeOperator, isCommaOperator); - emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 100 /* InKeyword */ ? writeKeyword : writeOperator); - emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); - maybePipelineEmitExpression(node.right); - break; - } - case 2 /* FinishEmit */: { - var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); - var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); - decreaseIndentIf(linesBeforeOperator, linesAfterOperator); - stackIndex--; - break; - } - default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker"); + function createEmitBinaryExpression() { + return ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, /*foldState*/ undefined); + function onEnter(node, state) { + if (state) { + state.stackIndex++; + state.preserveSourceNewlinesStack[state.stackIndex] = preserveSourceNewlines; + state.containerPosStack[state.stackIndex] = containerPos; + state.containerEndStack[state.stackIndex] = containerEnd; + state.declarationListContainerEndStack[state.stackIndex] = declarationListContainerEnd; + var emitComments_1 = state.shouldEmitCommentsStack[state.stackIndex] = shouldEmitComments(node); + var emitSourceMaps = state.shouldEmitSourceMapsStack[state.stackIndex] = shouldEmitSourceMaps(node); + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(node); + if (emitComments_1) + emitCommentsBeforeNode(node); + if (emitSourceMaps) + emitSourceMapsBeforeNode(node); + beforeEmitNode(node); } - } - function maybePipelineEmitExpression(next) { - // Advance the state of this unit of work, - stateStack[stackIndex]++; - // Then actually do the work of emitting the node `next` returned by the prior state - // The following section should be identical to `pipelineEmit` save it assumes EmitHint.Expression and offloads - // binary expression handling, where possible, to the contained work queue - // #region trampolinePipelineEmit - var savedLastNode = lastNode; - var savedLastSubstitution = lastSubstitution; - lastNode = next; - lastSubstitution = undefined; + else { + state = { + stackIndex: 0, + preserveSourceNewlinesStack: [undefined], + containerPosStack: [-1], + containerEndStack: [-1], + declarationListContainerEndStack: [-1], + shouldEmitCommentsStack: [false], + shouldEmitSourceMapsStack: [false], + }; + } + return state; + } + function onLeft(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "left"); + } + function onOperator(operatorToken, _state, node) { + var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); + var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); + writeLinesAndIndent(linesBeforeOperator, isCommaOperator); + emitLeadingCommentsOfPosition(operatorToken.pos); + writeTokenNode(operatorToken, operatorToken.kind === 100 /* InKeyword */ ? writeKeyword : writeOperator); + emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts + writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); + } + function onRight(next, _workArea, parent) { + return maybeEmitExpression(next, parent, "right"); + } + function onExit(node, state) { + var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); + var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); + decreaseIndentIf(linesBeforeOperator, linesAfterOperator); + if (state.stackIndex > 0) { + var savedPreserveSourceNewlines = state.preserveSourceNewlinesStack[state.stackIndex]; + var savedContainerPos = state.containerPosStack[state.stackIndex]; + var savedContainerEnd = state.containerEndStack[state.stackIndex]; + var savedDeclarationListContainerEnd = state.declarationListContainerEndStack[state.stackIndex]; + var shouldEmitComments_1 = state.shouldEmitCommentsStack[state.stackIndex]; + var shouldEmitSourceMaps_1 = state.shouldEmitSourceMapsStack[state.stackIndex]; + afterEmitNode(savedPreserveSourceNewlines); + if (shouldEmitSourceMaps_1) + emitSourceMapsAfterNode(node); + if (shouldEmitComments_1) + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(node); + state.stackIndex--; + } + } + function maybeEmitExpression(next, parent, side) { + var parenthesizerRule = side === "left" ? + parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); - if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) { - // If the target pipeline phase is emit directly, and the next node's also a binary expression, - // skip all the intermediate indirection and push the expression directly onto the work stack - stackIndex++; - stateStack[stackIndex] = 0 /* EmitLeft */; - nodeStack[stackIndex] = next; + if (pipelinePhase === pipelineEmitWithSubstitution) { + ts.Debug.assertIsDefined(lastSubstitution); + next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); + pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + lastSubstitution = undefined; } - else { - pipelinePhase(1 /* Expression */, next); + if (pipelinePhase === pipelineEmitWithComments || + pipelinePhase === pipelineEmitWithSourceMaps || + pipelinePhase === pipelineEmitWithHint) { + if (ts.isBinaryExpression(next)) { + return next; + } } - ts.Debug.assert(lastNode === next); - lastNode = savedLastNode; - lastSubstitution = savedLastSubstitution; - // #endregion trampolinePipelineEmit + currentParenthesizerRule = parenthesizerRule; + pipelinePhase(1 /* Expression */, next); } } function emitConditionalExpression(node) { @@ -102791,16 +105631,16 @@ var ts; var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue); var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken); var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse); - emitExpression(node.condition); + emitExpression(node.condition, parenthesizer.parenthesizeConditionOfConditionalExpression); writeLinesAndIndent(linesBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); writeLinesAndIndent(linesAfterQuestion, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenTrue); + emitExpression(node.whenTrue, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion); writeLinesAndIndent(linesBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); writeLinesAndIndent(linesAfterColon, /*writeSpaceIfNotIndenting*/ true); - emitExpression(node.whenFalse); + emitExpression(node.whenFalse, parenthesizer.parenthesizeBranchOfConditionalExpression); decreaseIndentIf(linesBeforeColon, linesAfterColon); } function emitTemplateExpression(node) { @@ -102810,22 +105650,22 @@ var ts; function emitYieldExpression(node) { emitTokenWithComment(124 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); - emitExpressionWithLeadingSpace(node.expression); + emitExpressionWithLeadingSpace(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } - function emitSpreadExpression(node) { + function emitSpreadElement(node) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { generateNameIfNeeded(node.name); emitClassDeclarationOrExpression(node); } function emitExpressionWithTypeArguments(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emitTypeArguments(node, node.typeArguments); } function emitAsExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, /*parenthesizerRules*/ undefined); if (node.type) { writeSpace(); writeKeyword("as"); @@ -102834,7 +105674,7 @@ var ts; } } function emitNonNullExpression(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); writeOperator("!"); } function emitMetaProperty(node) { @@ -102877,7 +105717,7 @@ var ts; } } function emitExpressionStatement(node) { - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement); // Emit semicolon in non json files // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation) if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) { @@ -102894,7 +105734,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); emitTokenWithComment(90 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 234 /* IfStatement */) { + if (node.elseStatement.kind === 235 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -102957,7 +105797,7 @@ var ts; emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(156 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(157 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -102965,7 +105805,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 250 /* VariableDeclarationList */) { + if (node.kind === 251 /* VariableDeclarationList */) { emit(node); } else { @@ -103002,7 +105842,7 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 283 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 284 /* JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; @@ -103066,7 +105906,7 @@ var ts; emit(node.name); emit(node.exclamationToken); emitTypeAnnotation(node.type); - emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node); + emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); @@ -103085,9 +105925,6 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } - function emitBlockCallback(_hint, body) { - emitBlockFunctionBody(body); - } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { @@ -103100,12 +105937,7 @@ var ts; ts.forEach(node.parameters, generateNames); generateNames(node.body); emitSignatureHead(node); - if (onEmitNode) { - onEmitNode(4 /* Unspecified */, body, emitBlockCallback); - } - else { - emitBlockFunctionBody(body); - } + emitBlockFunctionBody(body); popNameGenerationScope(node); if (indentedFlag) { decreaseIndent(); @@ -103114,7 +105946,7 @@ var ts; else { emitSignatureHead(node); writeSpace(); - emitExpression(body); + emitExpression(body, parenthesizer.parenthesizeConciseBodyOfArrowFunction); } } else { @@ -103158,6 +105990,7 @@ var ts; return true; } function emitBlockFunctionBody(body) { + onBeforeEmitNode === null || onBeforeEmitNode === void 0 ? void 0 : onBeforeEmitNode(body); writeSpace(); writePunctuation("{"); increaseIndent(); @@ -103172,6 +106005,7 @@ var ts; } decreaseIndent(); writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -103187,7 +106021,7 @@ var ts; increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, statementOffset); + emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -103262,7 +106096,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 256 /* ModuleDeclaration */) { + while (body && ts.isModuleDeclaration(body)) { writePunctuation("."); emit(body.name); body = body.body; @@ -103352,7 +106186,9 @@ var ts; emitTokenWithComment(87 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, node.isExportEquals ? + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(62 /* EqualsToken */) : + parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { @@ -103524,7 +106360,7 @@ var ts; function emitCaseClause(node) { emitTokenWithComment(81 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { @@ -103585,7 +106421,7 @@ var ts; var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } - emitExpression(initializer); + emitExpression(initializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitShorthandPropertyAssignment(node) { emit(node.name); @@ -103593,13 +106429,13 @@ var ts; writeSpace(); writePunctuation("="); writeSpace(); - emitExpression(node.objectAssignmentInitializer); + emitExpression(node.objectAssignmentInitializer, parenthesizer.parenthesizeExpressionForDisallowedComma); } } function emitSpreadAssignment(node) { if (node.expression) { emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); - emitExpression(node.expression); + emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } // @@ -103607,7 +106443,7 @@ var ts; // function emitEnumMember(node) { emit(node.name); - emitInitializer(node.initializer, node.name.end, node); + emitInitializer(node.initializer, node.name.end, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } // // JSDoc @@ -103615,18 +106451,21 @@ var ts; function emitJSDoc(node) { write("/**"); if (node.comment) { - var lines = node.comment.split(/\r\n?|\n/g); - for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { - var line = lines_2[_a]; - writeLine(); - writeSpace(); - writePunctuation("*"); - writeSpace(); - write(line); + var text = ts.getTextOfJSDocComment(node.comment); + if (text) { + var lines = text.split(/\r\n?|\n/g); + for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) { + var line = lines_2[_a]; + writeLine(); + writeSpace(); + writePunctuation("*"); + writeSpace(); + write(line); + } } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 329 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 333 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -103671,7 +106510,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 302 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -103690,7 +106529,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 312 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 314 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -103743,9 +106582,10 @@ var ts; emit(tagName); } function emitJSDocComment(comment) { - if (comment) { + var text = ts.getTextOfJSDocComment(comment); + if (text) { writeSpace(); - write(comment); + write(text); } } function emitJSDocTypeExpression(typeExpression) { @@ -103848,7 +106688,7 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes @@ -103856,7 +106696,7 @@ var ts; emitExpression(node.expression); } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */); + emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -104002,12 +106842,12 @@ var ts; emit(node); } } - function emitInitializer(node, equalCommentStartPos, container) { + function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitNodeWithPrefix(prefix, prefixWriter, node, emit) { @@ -104022,10 +106862,10 @@ var ts; emit(node); } } - function emitExpressionWithLeadingSpace(node) { + function emitExpressionWithLeadingSpace(node, parenthesizerRule) { if (node) { writeSpace(); - emitExpression(node); + emitExpression(node, parenthesizerRule); } } function emitWithTrailingSpace(node) { @@ -104055,7 +106895,7 @@ var ts; emitList(parentNode, decorators, 2146305 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */); + emitList(parentNode, typeArguments, 53776 /* TypeArguments */, parenthesizer.parenthesizeMemberOfElementType); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures @@ -104094,12 +106934,6 @@ var ts; function emitParametersForIndexSignature(parentNode, parameters) { emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); } - function emitList(parentNode, children, format, start, count) { - emitNodeList(emit, parentNode, children, format, start, count); - } - function emitExpressionList(parentNode, children, format, start, count) { - emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 - } function writeDelimiter(format) { switch (format & 60 /* DelimitersMask */) { case 0 /* None */: @@ -104122,7 +106956,13 @@ var ts; break; } } - function emitNodeList(emit, parentNode, children, format, start, count) { + function emitList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count); + } + function emitExpressionList(parentNode, children, format, parenthesizerRule, start, count) { + emitNodeList(emitExpression, parentNode, children, format, parenthesizerRule, start, count); + } + function emitNodeList(emit, parentNode, children, format, parenthesizerRule, start, count) { if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; @@ -104141,8 +106981,7 @@ var ts; } if (format & 15360 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists } } @@ -104151,7 +106990,7 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) { + if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { @@ -104159,6 +106998,7 @@ var ts; } } else { + ts.Debug.type(children); // Write the opening line terminator or leading whitespace. var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; @@ -104193,7 +107033,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== parentNode.end) { + if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -104226,7 +107066,12 @@ var ts; shouldEmitInterveningComments = mayEmitInterveningComments; } nextListElementPos = child.pos; - emit(child); + if (emit.length === 1) { + emit(child); + } + else { + emit(child, parenthesizerRule); + } if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); shouldDecreaseIndentAfterEmit = false; @@ -104251,7 +107096,7 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && parentNode.end !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end); } // Decrease the indent, if requested. @@ -104272,8 +107117,7 @@ var ts; onAfterEmitNodeArray(children); } if (format & 15360 /* BracketsMask */) { - if (isEmpty && !isUndefined) { - // TODO: GH#18217 + if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } writePunctuation(getClosingBracket(format)); @@ -104404,7 +107248,7 @@ var ts; } var firstChild_1 = children[0]; if (firstChild_1 === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (firstChild_1.pos === nextListElementPos) { // If this child starts at the beginning of a list item in a parent list, its leading @@ -104428,7 +107272,8 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - if (!ts.positionIsSynthesized(parentNode.pos) && + if (parentNode && + !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) { if (preserveSourceNewlines) { @@ -104451,10 +107296,10 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) { - if (preserveSourceNewlines) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } + else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { @@ -104473,9 +107318,9 @@ var ts; } var lastChild = ts.lastOrUndefined(children); if (lastChild === undefined) { - return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; + return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { + if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end; return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); }); @@ -104561,7 +107406,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 207 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 208 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -104631,84 +107476,84 @@ var ts; if (!node) return; switch (node.kind) { - case 230 /* Block */: + case 231 /* Block */: ts.forEach(node.statements, generateNames); break; - case 245 /* LabeledStatement */: - case 243 /* WithStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 246 /* LabeledStatement */: + case 244 /* WithStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: generateNames(node.statement); break; - case 234 /* IfStatement */: + case 235 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 238 /* ForStatement */: + case 240 /* ForOfStatement */: + case 239 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 258 /* CaseBlock */: + case 259 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 247 /* TryStatement */: + case 248 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 287 /* CatchClause */: + case 288 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: generateNames(node.declarationList); break; - case 250 /* VariableDeclarationList */: + case 251 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: + case 250 /* VariableDeclaration */: + case 161 /* Parameter */: + case 199 /* BindingElement */: + case 253 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 197 /* ObjectBindingPattern */: + case 198 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: generateNames(node.importClause); break; - case 262 /* ImportClause */: + case 263 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 269 /* NamespaceExport */: + case 270 /* NamespaceExport */: generateNameIfNeeded(node.name); break; - case 264 /* NamedImports */: + case 265 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 265 /* ImportSpecifier */: + case 266 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -104717,12 +107562,12 @@ var ts; if (!node) return; switch (node.kind) { - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 289 /* PropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: + case 164 /* PropertyDeclaration */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -104904,23 +107749,23 @@ var ts; switch (node.kind) { case 78 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: + case 257 /* ModuleDeclaration */: + case 256 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: + case 262 /* ImportDeclaration */: + case 268 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 266 /* ExportAssignment */: + case 252 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: + case 267 /* ExportAssignment */: return generateNameForExportDefault(); - case 221 /* ClassExpression */: + case 222 /* ClassExpression */: return generateNameForClassExpression(); - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -104963,25 +107808,45 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var savedContainerPos = containerPos; + var savedContainerEnd = containerEnd; + var savedDeclarationListContainerEnd = declarationListContainerEnd; + emitCommentsBeforeNode(node); + pipelinePhase(hint, node); + emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitCommentsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit leading comments + emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = true; + } + } + function emitCommentsAfterNode(node, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { + var emitFlags = ts.getEmitFlags(node); + var commentRange = ts.getCommentRange(node); + // Emit trailing comments + if (emitFlags & 2048 /* NoNestedComments */) { + commentsDisabled = false; + } + emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); + } + function emitLeadingCommentsOfNode(node, emitFlags, pos, end) { enterComment(); hasWrittenComment = false; - var emitFlags = ts.getEmitFlags(node); - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 335 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; // Save current container state on the stack. - var savedContainerPos = containerPos; - var savedContainerEnd = containerEnd; - var savedDeclarationListContainerEnd = declarationListContainerEnd; if ((pos > 0 || end > 0) && pos !== end) { // 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); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 339 /* 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. @@ -104992,23 +107857,17 @@ 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 === 250 /* VariableDeclarationList */) { + if (node.kind === 251 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } } ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment); exitComment(); - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); - if (emitFlags & 2048 /* NoNestedComments */) { - commentsDisabled = true; - pipelinePhase(hint, node); - commentsDisabled = false; - } - else { - pipelinePhase(hint, node); - } + } + function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -105017,12 +107876,11 @@ 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 && isEmittedNode) { + if (!skipTrailingComments && node.kind !== 339 /* NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); - ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -105082,6 +107940,23 @@ var ts; } exitComment(); } + function siblingNodePositionsAreComparable(previousNode, nextNode) { + if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { + return false; + } + if (nextNode.pos < previousNode.end) { + return false; + } + previousNode = ts.getOriginalNode(previousNode); + nextNode = ts.getOriginalNode(nextNode); + var parent = previousNode.parent; + if (!parent || parent !== nextNode.parent) { + return false; + } + var parentNodeArray = ts.getContainingNodeArray(previousNode); + var prevNodeIndex = parentNodeArray === null || parentNodeArray === void 0 ? void 0 : parentNodeArray.indexOf(previousNode); + return prevNodeIndex !== undefined && prevNodeIndex > -1 && parentNodeArray.indexOf(nextNode) === prevNodeIndex + 1; + } function emitLeadingComments(pos, isEmittedNode) { hasWrittenComment = false; if (isEmittedNode) { @@ -105254,42 +108129,49 @@ var ts; } return node.parsedSourceMap || undefined; } - function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assert(lastNode === node || lastSubstitution === node); + function pipelineEmitWithSourceMaps(hint, node) { var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); - if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { - pipelinePhase(hint, node); - } - else if (ts.isUnparsedNode(node)) { + emitSourceMapsBeforeNode(node); + pipelinePhase(hint, node); + emitSourceMapsAfterNode(node); + } + function emitSourceMapsBeforeNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit leading sourcemap + if (ts.isUnparsedNode(node)) { + ts.Debug.assertIsDefined(node.parent, "UnparsedNodes must have parent pointers"); var parsed = getParsedSourceMap(node.parent); if (parsed && sourceMapGenerator) { sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end)); } - pipelinePhase(hint, node); } else { - var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; - var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 335 /* NotEmittedStatement */ + var source = sourceMapRange.source || sourceMapSource; + if (node.kind !== 339 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 - && pos >= 0) { - emitSourcePos(source, skipSourceTrivia(source, pos)); + && sourceMapRange.pos >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } if (emitFlags & 64 /* NoNestedSourceMaps */) { sourceMapsDisabled = true; - pipelinePhase(hint, node); - sourceMapsDisabled = false; } - else { - pipelinePhase(hint, node); + } + } + function emitSourceMapsAfterNode(node) { + var emitFlags = ts.getEmitFlags(node); + var sourceMapRange = ts.getSourceMapRange(node); + // Emit trailing sourcemap + if (!ts.isUnparsedNode(node)) { + if (emitFlags & 64 /* NoNestedSourceMaps */) { + sourceMapsDisabled = false; } - if (node.kind !== 335 /* NotEmittedStatement */ + if (node.kind !== 339 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 - && end >= 0) { - emitSourcePos(source, end); + && sourceMapRange.end >= 0) { + emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } } - ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -105441,12 +108323,22 @@ var ts; return ts.getBaseFileName(ts.normalizePath(fileName)); } function createCachedFileSystemEntries(rootDir, rootDirPath) { - var resultFromHost = { - files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], - directories: host.getDirectories(rootDir) || [] - }; - cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); - return resultFromHost; + var _a; + if (!host.realpath || ts.ensureTrailingDirectorySeparator(toPath(host.realpath(rootDir))) === rootDirPath) { + var resultFromHost = { + files: ts.map(host.readDirectory(rootDir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || [], + directories: host.getDirectories(rootDir) || [] + }; + cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost); + return resultFromHost; + } + // If the directory is symlink do not cache the result + if ((_a = host.directoryExists) === null || _a === void 0 ? void 0 : _a.call(host, rootDir)) { + cachedReadDirectoryResult.set(rootDirPath, false); + return false; + } + // Non existing directory + return undefined; } /** * If the readDirectory result was already cached, it returns that @@ -105521,17 +108413,32 @@ var ts; } function readDirectory(rootDir, extensions, excludes, includes, depth) { var rootDirPath = toPath(rootDir); - var result = tryReadDirectory(rootDir, rootDirPath); - if (result) { + var rootResult = tryReadDirectory(rootDir, rootDirPath); + var rootSymLinkResult; + if (rootResult !== undefined) { return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath); } return host.readDirectory(rootDir, extensions, excludes, includes, depth); function getFileSystemEntries(dir) { var path = toPath(dir); if (path === rootDirPath) { - return result; - } - return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries; + return rootResult || getFileSystemEntriesFromHost(dir, path); + } + var result = tryReadDirectory(dir, path); + return result !== undefined ? + result || getFileSystemEntriesFromHost(dir, path) : + ts.emptyFileSystemEntries; + } + function getFileSystemEntriesFromHost(dir, path) { + if (rootSymLinkResult && path === rootDirPath) + return rootSymLinkResult; + var result = { + files: ts.map(host.readDirectory(dir, /*extensions*/ undefined, /*exclude*/ undefined, /*include*/ ["*.*"]), getBaseNameOfFileName) || ts.emptyArray, + directories: host.getDirectories(dir) || ts.emptyArray + }; + if (path === rootDirPath) + rootSymLinkResult = result; + return result; } } function realpath(s) { @@ -105539,7 +108446,7 @@ var ts; } function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) { var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath); - if (existingResult) { + if (existingResult !== undefined) { // Just clear the cache for now // For now just clear the cache, since this could mean that multiple level entries might need to be re-evaluated clearCache(); @@ -105599,9 +108506,9 @@ var ts; /** * Updates the map of shared extended config file watches with a new set of extended config files from a base config file of the project */ - function updateSharedExtendedConfigFileWatcher(projectPath, parsed, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { + function updateSharedExtendedConfigFileWatcher(projectPath, options, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) { var _a; - var extendedConfigs = ts.arrayToMap(((_a = parsed === null || parsed === void 0 ? void 0 : parsed.options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); + var extendedConfigs = ts.arrayToMap(((_a = options === null || options === void 0 ? void 0 : options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath); // remove project from all unrelated watchers extendedConfigFilesMap.forEach(function (watcher, extendedConfigFilePath) { if (!extendedConfigs.has(extendedConfigFilePath)) { @@ -105619,12 +108526,12 @@ var ts; // start watching previously unseen extended config extendedConfigFilesMap.set(extendedConfigFilePath, { projects: new ts.Set([projectPath]), - fileWatcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), + watcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath), close: function () { var existing = extendedConfigFilesMap.get(extendedConfigFilePath); if (!existing || existing.projects.size !== 0) return; - existing.fileWatcher.close(); + existing.watcher.close(); extendedConfigFilesMap.delete(extendedConfigFilePath); }, }); @@ -105632,6 +108539,31 @@ var ts; }); } ts.updateSharedExtendedConfigFileWatcher = updateSharedExtendedConfigFileWatcher; + /** + * Remove the project from the extended config file watchers and close not needed watches + */ + function clearSharedExtendedConfigFileWatcher(projectPath, extendedConfigFilesMap) { + extendedConfigFilesMap.forEach(function (watcher) { + if (watcher.projects.delete(projectPath)) + watcher.close(); + }); + } + ts.clearSharedExtendedConfigFileWatcher = clearSharedExtendedConfigFileWatcher; + /** + * Clean the extendsConfigCache when extended config file has changed + */ + function cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath) { + if (!extendedConfigCache.delete(extendedConfigFilePath)) + return; + extendedConfigCache.forEach(function (_a, key) { + var _b; + var extendedResult = _a.extendedResult; + if ((_b = extendedResult.extendedSourceFiles) === null || _b === void 0 ? void 0 : _b.some(function (extendedFile) { return toPath(extendedFile) === extendedConfigFilePath; })) { + cleanExtendedConfigCache(extendedConfigCache, key, toPath); + } + }); + } + ts.cleanExtendedConfigCache = cleanExtendedConfigCache; /** * Updates the existing missing file watches with the new set of missing files after new program is created */ @@ -105683,7 +108615,7 @@ var ts; ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories; /* @internal */ function isIgnoredFileFromWildCardWatching(_a) { - var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog; + var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); @@ -105719,7 +108651,8 @@ var ts; } // just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); - var realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program; + var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; + var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); @@ -105729,7 +108662,9 @@ var ts; function hasSourceFile(file) { return realProgram ? !!realProgram.getSourceFileByPath(file) : - program.getState().fileInfos.has(file); + builderProgram ? + builderProgram.getState().fileInfos.has(file) : + !!ts.find(program, function (rootFile) { return toPath(rootFile) === file; }); } } ts.isIgnoredFileFromWildCardWatching = isIgnoredFileFromWildCardWatching; @@ -106408,38 +109343,31 @@ var ts; * Determines if program structure is upto date or needs to be recreated */ /* @internal */ - function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) { + function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) { // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date - if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) { + if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) return false; - } // If root file names don't match - if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) { + if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) return false; - } var seenResolvedRefs; // If project references don't match - if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) { + if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) return false; - } // If any file is not up-to-date, then the whole program is not up-to-date - if (program.getSourceFiles().some(sourceFileNotUptoDate)) { + if (program.getSourceFiles().some(sourceFileNotUptoDate)) return false; - } // If any of the missing file paths are now created - if (program.getMissingFilePaths().some(fileExists)) { + if (program.getMissingFilePaths().some(fileExists)) return false; - } var currentOptions = program.getCompilerOptions(); // If the compilation settings do no match, then the program is not up-to-date - if (!ts.compareDataObjects(currentOptions, newOptions)) { + if (!ts.compareDataObjects(currentOptions, newOptions)) return false; - } // If everything matches but the text of config file is changed, // error locations can change for program options, so update the program - if (currentOptions.configFile && newOptions.configFile) { + if (currentOptions.configFile && newOptions.configFile) return currentOptions.configFile.text === newOptions.configFile.text; - } return true; function sourceFileNotUptoDate(sourceFile) { return !sourceFileVersionUptoDate(sourceFile) || @@ -106449,21 +109377,25 @@ var ts; return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName); } function projectReferenceUptoDate(oldRef, newRef, index) { - if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { - return false; - } - return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); + return ts.projectReferenceIsEqualTo(oldRef, newRef) && + resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef); } function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) { if (oldResolvedRef) { - if (ts.contains(seenResolvedRefs, oldResolvedRef)) { - // Assume true + // Assume true + if (ts.contains(seenResolvedRefs, oldResolvedRef)) return true; - } - // If sourceFile for the oldResolvedRef existed, check the version for uptodate - if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) { + var refPath_1 = resolveProjectReferencePath(oldRef); + var newParsedCommandLine = getParsedCommandLine(refPath_1); + // Check if config file exists + if (!newParsedCommandLine) + return false; + // If change in source file + if (oldResolvedRef.commandLine.options.configFile !== newParsedCommandLine.options.configFile) + return false; + // check file names + if (!ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newParsedCommandLine.fileNames)) return false; - } // Add to seen before checking the referenced paths of this config file (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef); // If child project references are upto date, this project reference is uptodate @@ -106473,7 +109405,8 @@ var ts; } // In old program, not able to resolve project reference path, // so if config file doesnt exist, it is uptodate. - return !fileExists(resolveProjectReferencePath(oldRef)); + var refPath = resolveProjectReferencePath(oldRef); + return !getParsedCommandLine(refPath); } } ts.isProgramUptoDate = isProgramUptoDate; @@ -106552,6 +109485,7 @@ var ts; var hasEmitBlockingDiagnostics = new ts.Map(); var _compilerOptionsObjectLiteralSyntax; var moduleResolutionCache; + var typeReferenceDirectiveResolutionCache; var actualResolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { @@ -106566,7 +109500,7 @@ var ts; }); }; } else { - moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options); + 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); }; } @@ -106575,7 +109509,8 @@ var ts; actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { - var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 + typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()); + var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; // TODO: GH#18217 actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); }; } // Map from a stringified PackageId to the source file with that id. @@ -106714,12 +109649,25 @@ var ts; host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } } - oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { - if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { - host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + if (!host.getParsedCommandLine) { + oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) { + if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) { + host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), /*hasSourceFileByPath*/ false); + } + }); + } + } + // Release commandlines that new program does not use + if (oldProgram && host.onReleaseParsedCommandLine) { + forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) { + var oldReference = (parent === null || parent === void 0 ? void 0 : parent.commandLine.projectReferences[index]) || oldProgram.getProjectReferences()[index]; + var oldRefPath = resolveProjectReferencePath(oldReference); + if (!(projectReferenceRedirects === null || projectReferenceRedirects === void 0 ? void 0 : projectReferenceRedirects.has(toPath(oldRefPath)))) { + host.onReleaseParsedCommandLine(oldRefPath, oldResolvedRef, oldProgram.getCompilerOptions()); } }); } + typeReferenceDirectiveResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; var program = { @@ -106748,7 +109696,6 @@ var ts; getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); }, getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, - getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); }, getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); }, @@ -106914,13 +109861,13 @@ var ts; // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - var result_14 = []; + var result_15 = []; 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); + result_15.push(resolvedModule); } - return result_14; + return result_15; } // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules @@ -107031,7 +109978,9 @@ var ts; var newResolvedRef = parseProjectReferenceConfigFile(newRef); if (oldResolvedRef) { // Resolved project reference has gone missing or changed - return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile; + return !newResolvedRef || + newResolvedRef.sourceFile !== oldResolvedRef.sourceFile || + !ts.arrayIsEqualTo(oldResolvedRef.commandLine.fileNames, newResolvedRef.commandLine.fileNames); } else { // A previously-unresolved reference may be resolved now @@ -107554,22 +110503,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 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: + case 161 /* Parameter */: + case 164 /* PropertyDeclaration */: + case 166 /* 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 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 249 /* VariableDeclaration */: + case 165 /* MethodSignature */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 209 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 210 /* ArrowFunction */: + case 250 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -107577,58 +110526,58 @@ var ts; } } switch (node.kind) { - case 262 /* ImportClause */: + case 263 /* 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 267 /* ExportDeclaration */: + case 268 /* 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 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 286 /* HeritageClause */: + case 287 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 116 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 253 /* InterfaceDeclaration */: + case 254 /* InterfaceDeclaration */: var interfaceKeyword = ts.tokenToString(117 /* InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(140 /* NamespaceKeyword */) : ts.tokenToString(139 /* ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 254 /* TypeAliasDeclaration */: + case 255 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91 /* EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 225 /* NonNullExpression */: + case 226 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 224 /* AsExpression */: + case 225 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 206 /* TypeAssertionExpression */: + case 207 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -107637,29 +110586,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 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 166 /* MethodDeclaration */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 209 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 210 /* ArrowFunction */: // 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 232 /* VariableStatement */: + case 233 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 232 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 233 /* VariableStatement */); return "skip"; } break; - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -107671,19 +110620,19 @@ var ts; return "skip"; } break; - case 160 /* Parameter */: + case 161 /* 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 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: - case 205 /* TaggedTemplateExpression */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: + case 224 /* ExpressionWithTypeArguments */: + case 275 /* JsxSelfClosingElement */: + case 276 /* JsxOpeningElement */: + case 206 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -107708,6 +110657,7 @@ var ts; case 142 /* ReadonlyKeyword */: case 133 /* DeclareKeyword */: case 125 /* AbstractKeyword */: + case 156 /* 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. @@ -108349,12 +111299,14 @@ var ts; return host.getCanonicalFileName(fileName); } function processImportedModules(file) { + var _a; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. var moduleNames = getModuleNames(file); var resolutions = resolveModuleNamesReusingOldState(moduleNames, file); ts.Debug.assert(resolutions.length === moduleNames.length); + 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); @@ -108377,11 +111329,11 @@ var ts; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. var shouldAddFile = resolvedFileName - && !getResolutionDiagnostic(options, resolution) - && !options.noResolve + && !getResolutionDiagnostic(optionsForFile, resolution) + && !optionsForFile.noResolve && index < file.imports.length && !elideImport - && !(isJsFile && !ts.getAllowJSCompilerOption(options)) + && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -108617,9 +111569,10 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module"); } } - // there has to be common source directory if user specified --outdir || --sourceRoot + // there has to be common source directory if user specified --outdir || --rootDir || --sourceRoot // if user specified --mapRoot, there needs to be common source directory if there would be multiple files being emitted if (options.outDir || // there is --outDir specified + options.rootDir || // there is --rootDir specified options.sourceRoot || // there is --sourceRoot specified options.mapRoot) { // there is --mapRoot specified // Precalculate and cache the common source directory @@ -109409,12 +112362,15 @@ var ts; // From ambient modules for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) { var ambientModule = _g[_f]; - if (ambientModule.declarations.length > 1) { + if (ambientModule.declarations && ambientModule.declarations.length > 1) { addReferenceFromAmbientModule(ambientModule); } } return referencedFiles; function addReferenceFromAmbientModule(symbol) { + if (!symbol.declarations) { + return; + } // Add any file other than our own as reference for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; @@ -109439,7 +112395,7 @@ var ts; /** * Creates the state of file references and signature for the new program from oldState if it is safe */ - function create(newProgram, getCanonicalFileName, oldState) { + function create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { var fileInfos = new ts.Map(); var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined; var exportedModulesMap = referencedMap ? new ts.Map() : undefined; @@ -109465,13 +112421,14 @@ var ts; } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) }); + fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined }); } return { fileInfos: fileInfos, referencedMap: referencedMap, exportedModulesMap: exportedModulesMap, - hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature + hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature, + useFileVersionAsSignature: !disableUseFileVersionAsSignature && !useOldState }; } BuilderState.create = create; @@ -109493,6 +112450,7 @@ var ts; referencedMap: state.referencedMap && new ts.Map(state.referencedMap), exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap), hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature), + useFileVersionAsSignature: state.useFileVersionAsSignature, }; } BuilderState.clone = clone; @@ -109548,23 +112506,12 @@ var ts; return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; - if (sourceFile.isDeclarationFile) { - latestSignature = sourceFile.version; - if (exportedModulesMapCache && latestSignature !== prevSignature) { - // All the references in this file are exported - var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; - exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); - } - } - else { + if (!sourceFile.isDeclarationFile && !state.useFileVersionAsSignature) { var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken, /*customTransformers*/ undefined, /*forceDtsEmit*/ true); - var firstDts_1 = emitOutput_1.outputFiles && - programOfThisState.getCompilerOptions().declarationMap ? - emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : - emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined; + 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; })); }); latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text); @@ -109572,12 +112519,18 @@ var ts; updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache); } } - else { - latestSignature = prevSignature; // TODO: GH#18217 + } + // Default is to use file version as signature + if (latestSignature === undefined) { + latestSignature = sourceFile.version; + if (exportedModulesMapCache && latestSignature !== prevSignature) { + // All the references in this file are exported + var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined; + exportedModulesMapCache.set(sourceFile.resolvedPath, references || false); } } cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature); - return !prevSignature || latestSignature !== prevSignature; + return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; /** @@ -109697,7 +112650,7 @@ var ts; */ function isFileAffectingGlobalScope(sourceFile) { return containsGlobalScopeAugmentation(sourceFile) || - !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); + !ts.isExternalOrCommonJsModule(sourceFile) && !containsOnlyAmbientModules(sourceFile); } /** * Gets all files of the program excluding the default library file @@ -109785,8 +112738,8 @@ var ts; /** * Create the state so that we can iterate on changedFiles/affected files */ - function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) { - var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState); + function createBuilderProgramState(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature) { + var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState, disableUseFileVersionAsSignature); state.program = newProgram; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; @@ -110024,6 +112977,7 @@ var ts; * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) { + var _a; removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -110037,8 +112991,15 @@ var ts; removeSemanticDiagnosticsOf(state, f.resolvedPath); }); } + // When a change affects the global scope, all files are considered to be affected without updating their signature + // That means when affected file is handled, its signature can be out of date + // To avoid this, ensure that we update the signature for any affected file in this scenario. + ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); return; } + else { + ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName); + } if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) { forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); }); } @@ -110250,83 +113211,116 @@ var ts; return undefined; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - var fileInfos = {}; - state.fileInfos.forEach(function (value, key) { + var fileNames = []; + var fileNameToFileId = new ts.Map(); + var fileIdsList; + var fileNamesToFileIdListId; + var fileInfos = ts.arrayFrom(state.fileInfos.entries(), function (_a) { + var key = _a[0], value = _a[1]; + // Ensure fileId + var fileId = toFileId(key); + ts.Debug.assert(fileNames[fileId - 1] === relativeToBuildInfo(key)); var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); - fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope }; + var actualSignature = signature !== null && signature !== void 0 ? signature : value.signature; + return value.version === actualSignature ? + value.affectsGlobalScope ? + { version: value.version, signature: undefined, affectsGlobalScope: true } : + value.version : + actualSignature !== undefined ? + signature === undefined ? + value : + { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope } : + { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope }; }); - var result = { - fileInfos: fileInfos, - options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath) - }; + var referencedMap; if (state.referencedMap) { - var referencedMap = {}; - for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { - var key = _a[_i]; - referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.referencedMap = referencedMap; + referencedMap = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive).map(function (key) { return [ + toFileId(key), + toFileIdListId(state.referencedMap.get(key)) + ]; }); } + var exportedModulesMap; if (state.exportedModulesMap) { - var exportedModulesMap = {}; - for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { - var key = _c[_b]; + exportedModulesMap = ts.mapDefined(ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive), function (key) { var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); // Not in temporary cache, use existing value if (newValue === undefined) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); + return [toFileId(key), toFileIdListId(state.exportedModulesMap.get(key))]; // Value in cache and has updated value map, use that else if (newValue) - exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); - } - result.exportedModulesMap = exportedModulesMap; + return [toFileId(key), toFileIdListId(newValue)]; + }); } + var semanticDiagnosticsPerFile; if (state.semanticDiagnosticsPerFile) { - var semanticDiagnosticsPerFile = []; - for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) { - var key = _e[_d]; + for (var _i = 0, _a = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var key = _a[_i]; var value = state.semanticDiagnosticsPerFile.get(key); - semanticDiagnosticsPerFile.push(value.length ? + (semanticDiagnosticsPerFile || (semanticDiagnosticsPerFile = [])).push(value.length ? [ - relativeToBuildInfo(key), + toFileId(key), state.hasReusableDiagnostic ? value : convertToReusableDiagnostics(value, relativeToBuildInfo) ] : - relativeToBuildInfo(key)); + toFileId(key)); } - result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile; } + var affectedFilesPendingEmit; if (state.affectedFilesPendingEmit) { - var affectedFilesPendingEmit = []; var seenFiles = new ts.Set(); - for (var _f = 0, _g = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _f < _g.length; _f++) { - var path = _g[_f]; + for (var _b = 0, _c = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { + var path = _c[_b]; if (ts.tryAddToSet(seenFiles, path)) { - affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind.get(path)]); + (affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push([toFileId(path), state.affectedFilesPendingEmitKind.get(path)]); } } - result.affectedFilesPendingEmit = affectedFilesPendingEmit; } - return result; + return { + fileNames: fileNames, + fileInfos: fileInfos, + options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath), + fileIdsList: fileIdsList, + referencedMap: referencedMap, + exportedModulesMap: exportedModulesMap, + semanticDiagnosticsPerFile: semanticDiagnosticsPerFile, + affectedFilesPendingEmit: affectedFilesPendingEmit, + }; function relativeToBuildInfoEnsuringAbsolutePath(path) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory)); } function relativeToBuildInfo(path) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName)); } + function toFileId(path) { + var fileId = fileNameToFileId.get(path); + if (fileId === undefined) { + fileNames.push(relativeToBuildInfo(path)); + fileNameToFileId.set(path, fileId = fileNames.length); + } + return fileId; + } + function toFileIdListId(set) { + var fileIds = ts.arrayFrom(set.keys(), toFileId).sort(ts.compareValues); + var key = fileIds.join(); + var fileIdListId = fileNamesToFileIdListId === null || fileNamesToFileIdListId === void 0 ? void 0 : fileNamesToFileIdListId.get(key); + if (fileIdListId === undefined) { + (fileIdsList || (fileIdsList = [])).push(fileIds); + (fileNamesToFileIdListId || (fileNamesToFileIdListId = new ts.Map())).set(key, fileIdListId = fileIdsList.length); + } + return fileIdListId; + } } - function convertToReusableCompilerOptions(options, relativeToBuildInfo) { - var result = {}; + function convertToProgramBuildInfoCompilerOptions(options, relativeToBuildInfo) { + var result; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo); + for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var name = _a[_i]; + var optionInfo = optionsNameMap.get(name.toLowerCase()); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } - if (result.configFilePath) { - result.configFilePath = relativeToBuildInfo(result.configFilePath); - } return result; } function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) { @@ -110418,7 +113412,7 @@ var ts; * Computing hash to for signature verification */ var computeHash = ts.maybeBind(host, host.createHash); - var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); + var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); var backupState; newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); }; // To ensure that we arent storing any references to old program or new program without state @@ -110642,37 +113636,31 @@ var ts; state.affectedFilesPendingEmitIndex = 0; } } - function getMapOfReferencedSet(mapLike, toPath) { - if (!mapLike) - return undefined; - var map = new ts.Map(); - // Copies keys/values from template. Note that for..in will not throw if - // template is undefined, and instead will just exit the loop. - for (var key in mapLike) { - if (ts.hasProperty(mapLike, key)) { - map.set(toPath(key), new ts.Set(mapLike[key].map(toPath))); - } - } - return map; + function toBuilderStateFileInfo(fileInfo) { + return ts.isString(fileInfo) ? + { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } : + ts.isString(fileInfo.signature) ? + fileInfo : + { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope }; } + ts.toBuilderStateFileInfo = toBuilderStateFileInfo; function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) { + var _a; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); + var filePaths = program.fileNames.map(toPath); + var filePathsSetList = (_a = program.fileIdsList) === null || _a === void 0 ? void 0 : _a.map(function (fileIds) { return new ts.Set(fileIds.map(toFilePath)); }); var fileInfos = new ts.Map(); - for (var key in program.fileInfos) { - if (ts.hasProperty(program.fileInfos, key)) { - fileInfos.set(toPath(key), program.fileInfos[key]); - } - } + program.fileInfos.forEach(function (fileInfo, index) { return fileInfos.set(toFilePath(index + 1), toBuilderStateFileInfo(fileInfo)); }); var state = { fileInfos: fileInfos, - compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), - referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), - exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), - semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), + compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, + referencedMap: toMapOfReferencedSet(program.referencedMap), + exportedModulesMap: toMapOfReferencedSet(program.exportedModulesMap), + semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toFilePath(ts.isNumber(value) ? value : value[0]); }, function (value) { return ts.isNumber(value) ? ts.emptyArray : value[1]; }), hasReusableDiagnostic: true, - affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }), - affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }, function (value) { return value[1]; }), + affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }), + affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, }; return { @@ -110705,6 +113693,15 @@ var ts; function toAbsolutePath(path) { return ts.getNormalizedAbsolutePath(path, buildInfoDirectory); } + function toFilePath(fileId) { + return filePaths[fileId - 1]; + } + function toFilePathsSet(fileIdsListId) { + return filePathsSetList[fileIdsListId - 1]; + } + function toMapOfReferencedSet(referenceMap) { + return referenceMap && ts.arrayToMap(referenceMap, function (value) { return toFilePath(value[0]); }, function (value) { return toFilePathsSet(value[1]); }); + } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { @@ -110817,9 +113814,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolvedFileToResolution = ts.createMultiMap(); var hasChangedAutomaticTypeDirectiveNames = false; - var failedLookupChecks = []; - var startsWithPathChecks = []; - var isInDirectoryChecks = []; + var failedLookupChecks; + var startsWithPathChecks; + var isInDirectoryChecks; var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217 var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost(); // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file. @@ -110828,9 +113825,12 @@ var ts; var resolvedModuleNames = new ts.Map(); var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects(); var nonRelativeModuleNameCache = ts.createCacheWithRedirects(); - var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName); + var moduleResolutionCache = ts.createModuleResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache); var resolvedTypeReferenceDirectives = new ts.Map(); var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects(); + var typeReferenceDirectiveResolutionCache = ts.createTypeReferenceDirectiveResolutionCache(getCurrentDirectory(), resolutionHost.getCanonicalFileName, + /*options*/ undefined, moduleResolutionCache.getPackageJsonInfoCache(), perDirectoryResolvedTypeReferenceDirectives); /** * These are the extensions that failed lookup files will have by default, * any other extension of failed lookup will be store that path in custom failed lookup path @@ -110888,9 +113888,9 @@ var ts; resolvedTypeReferenceDirectives.clear(); resolvedFileToResolution.clear(); resolutionsWithFailedLookups.length = 0; - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) clearPerDirectoryResolutions(); @@ -110926,9 +113926,8 @@ var ts; isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { - perDirectoryResolvedModuleNames.clear(); - nonRelativeModuleNameCache.clear(); - perDirectoryResolvedTypeReferenceDirectives.clear(); + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } @@ -110955,7 +113954,7 @@ var ts; if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) { // create different collection of failed lookup locations for second pass // if it will fail and we've already found something during the first pass - we don't want to pollute its results - var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; + var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache, moduleResolutionCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; if (resolvedModule) { // Modify existing resolution so its saved in the directory cache as well primaryResult.resolvedModule = resolvedModule; @@ -110966,6 +113965,9 @@ var ts; // Default return the result from the first pass return primaryResult; } + function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) { + return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache); + } function resolveNamesWithLocalCache(_a) { var _b; 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; @@ -111053,7 +114055,7 @@ var ts; redirectedReference: redirectedReference, cache: resolvedTypeReferenceDirectives, perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives, - loader: ts.resolveTypeReferenceDirective, + loader: resolveTypeReferenceDirective, getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, }); @@ -111328,7 +114330,7 @@ var ts; if (isCreatingWatchedDirectory) { // Watching directory is created // Invalidate any resolution has failed lookup in this directory - isInDirectoryChecks.push(fileOrDirectoryPath); + (isInDirectoryChecks || (isInDirectoryChecks = [])).push(fileOrDirectoryPath); } else { // If something to do with folder/file starting with "." in node_modules folder, skip it @@ -111346,8 +114348,8 @@ var ts; if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) || isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) { // Invalidate any resolution from this directory - failedLookupChecks.push(fileOrDirectoryPath); - startsWithPathChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(fileOrDirectoryPath); } else { if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) { @@ -111358,27 +114360,33 @@ var ts; return false; } // Resolution need to be invalidated if failed lookup location is same as the file or directory getting created - failedLookupChecks.push(fileOrDirectoryPath); + (failedLookupChecks || (failedLookupChecks = [])).push(fileOrDirectoryPath); + // If the invalidated file is from a node_modules package, invalidate everything else + // in the package since we might not get notifications for other files in the package. + // This hardens our logic against unreliable file watchers. + var packagePath = ts.parseNodeModuleFromPath(fileOrDirectoryPath); + if (packagePath) + (startsWithPathChecks || (startsWithPathChecks = new ts.Set())).add(packagePath); } } resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { - if (!failedLookupChecks.length && !startsWithPathChecks.length && !isInDirectoryChecks.length) { + if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) { return false; } var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); - failedLookupChecks.length = 0; - startsWithPathChecks.length = 0; - isInDirectoryChecks.length = 0; + failedLookupChecks = undefined; + startsWithPathChecks = undefined; + isInDirectoryChecks = undefined; return invalidated; } function canInvalidateFailedLookupResolution(resolution) { return resolution.failedLookupLocations.some(function (location) { var locationPath = resolutionHost.toPath(location); return ts.contains(failedLookupChecks, locationPath) || - startsWithPathChecks.some(function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath); }) || - isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); }); + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + (isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); })); }); } function closeTypeRootsWatch() { @@ -111529,6 +114537,9 @@ var ts; return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); + if (!moduleSourceFile) { + return []; + } var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) { @@ -111599,7 +114610,7 @@ var ts; if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { return relativePath; } - var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl; + var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName); if (!relativeToBaseUrl) { return relativePath; @@ -111614,7 +114625,9 @@ var ts; return nonRelative; } if (relativePreference === 3 /* ExternalNonRelative */) { - var projectDirectory = host.getCurrentDirectory(); + var projectDirectory = compilerOptions.configFilePath ? + ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : + info.getCanonicalFileName(host.getCurrentDirectory()); var modulePath = ts.toPath(moduleFileName, projectDirectory, getCanonicalFileName); var sourceIsInternal = ts.startsWith(sourceDirectory, projectDirectory); var targetIsInternal = ts.startsWith(modulePath, projectDirectory); @@ -111689,9 +114702,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_16 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); }); + if (result_16) + return result_16; } var links = host.getSymlinkCache ? host.getSymlinkCache() @@ -111714,10 +114727,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_17 = 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_17) + return result_17; } }); }); @@ -111731,8 +114744,14 @@ var ts; * Symlinks will be returned first so they are preferred over the real path. */ function getAllModulePaths(importingFileName, importedFileName, host) { - var cwd = host.getCurrentDirectory(); + var _a; + var cache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + if (cache) { + var cached = cache.get(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName)); + if (typeof cached === "object") + return cached; + } var allFileNames = new ts.Map(); var importedFileFromNodeModules = false; forEachFileNameOfModule(importingFileName, importedFileName, host, @@ -111744,7 +114763,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_24 = function (directory) { + var _loop_26 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -111767,10 +114786,10 @@ var ts; out_directory_1 = directory; }; var out_directory_1; - for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { - var state_8 = _loop_24(directory); + for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { + var state_9 = _loop_26(directory); directory = out_directory_1; - if (state_8 === "break") + if (state_9 === "break") break; } if (allFileNames.size) { @@ -111779,10 +114798,14 @@ var ts; remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators); sortedPaths.push.apply(sortedPaths, remainingPaths); } + if (cache) { + cache.set(importingFileName, ts.toPath(importedFileName, host.getCurrentDirectory(), getCanonicalFileName), sortedPaths); + } return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) { - var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); + var _a; + var decl = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); if (decl) { return decl.name.text; } @@ -111838,7 +114861,7 @@ var ts; ts.startsWith(relativeToBaseUrl, prefix) && ts.endsWith(relativeToBaseUrl, suffix) || !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length); + var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); return key.replace("*", matchedStar); } } @@ -112142,10 +115165,10 @@ var ts; } ts.createWatchStatusReporter = createWatchStatusReporter; /** Parses config file using System interface */ - function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) { + function parseConfigFileWithSystem(configFileName, optionsToExtend, extendedConfigCache, watchOptionsToExtend, system, reportDiagnostic) { var host = system; host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; - var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, /*extendedConfigCache*/ undefined, watchOptionsToExtend); + var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; } @@ -112413,7 +115436,10 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", - TypeRoots: "Type roots" + TypeRoots: "Type roots", + ConfigFileOfReferencedProject: "Config file of referened project", + ExtendedConfigOfReferencedProject: "Extended config file of referenced project", + WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", }; function createWatchFactory(host, options) { var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; @@ -112460,6 +115486,7 @@ var ts; getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }), createHash: ts.maybeBind(host, host.createHash), readDirectory: ts.maybeBind(host, host.readDirectory), + disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -112517,7 +115544,8 @@ var ts; createDirectory: function (path) { return system.createDirectory(path); }, writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, createHash: ts.maybeBind(system, system.createHash), - createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram + createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram, + disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature, }; } ts.createProgramHost = createProgramHost; @@ -112605,6 +115633,7 @@ var ts; if (system === void 0) { system = ts.sys; } var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system); host.createHash = ts.maybeBind(system, system.createHash); + host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -112648,11 +115677,13 @@ var ts; function createWatchProgram(host) { var builderProgram; var reloadLevel; // level to indicate if the program needs to be reloaded from config file/just filenames etc - var extendedConfigFilesMap; // Map of file watchers for the extended config files var missingFilesMap; // Map of file watchers for the missing files var watchedWildcardDirectories; // map of watchers for the wild card directories in the config file var timerToUpdateProgram; // timer callback to recompile the program var timerToInvalidateFailedLookupResolutions; // timer callback to invalidate resolutions for changes in failed lookup locations + var parsedConfigs; // Parsed commandline and watching cached for referenced projects + var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects + var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations @@ -112702,6 +115733,7 @@ var ts; compilerHost.getNewLine = function () { return newLine; }; compilerHost.fileExists = fileExists; compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile; + compilerHost.onReleaseParsedCommandLine = onReleaseParsedCommandLine; // Members for ResolutionCacheHost compilerHost.toPath = toPath; compilerHost.getCompilationSettings = function () { return compilerOptions; }; @@ -112715,6 +115747,7 @@ var ts; compilerHost.fileIsOpen = ts.returnFalse; compilerHost.getCurrentProgram = getCurrentProgram; compilerHost.writeLog = writeLog; + compilerHost.getParsedCommandLine = getParsedCommandLine; // Cache for the module resolution var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ? ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) : @@ -112745,7 +115778,8 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + if (configFileName) + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); return configFileName ? { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } : { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close }; @@ -112762,9 +115796,11 @@ var ts; configFileWatcher.close(); configFileWatcher = undefined; } - if (extendedConfigFilesMap) { - ts.clearMap(extendedConfigFilesMap, ts.closeFileWatcher); - extendedConfigFilesMap = undefined; + extendedConfigCache === null || extendedConfigCache === void 0 ? void 0 : extendedConfigCache.clear(); + extendedConfigCache = undefined; + if (sharedExtendedConfigFileWatchers) { + ts.clearMap(sharedExtendedConfigFileWatchers, ts.closeFileWatcherOf); + sharedExtendedConfigFileWatchers = undefined; } if (watchedWildcardDirectories) { ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); @@ -112774,6 +115810,17 @@ var ts; ts.clearMap(missingFilesMap, ts.closeFileWatcher); missingFilesMap = undefined; } + if (parsedConfigs) { + ts.clearMap(parsedConfigs, function (config) { + var _a; + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + config.watcher = undefined; + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + config.watchedDirectories = undefined; + }); + parsedConfigs = undefined; + } } function getCurrentBuilderProgram() { return builderProgram; @@ -112793,7 +115840,7 @@ var ts; } // All resolutions are invalid if user provided resolutions var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); hasChangedConfigFileParsingErrors = false; @@ -112812,6 +115859,8 @@ var ts; writeLog("CreatingProgramWith::"); writeLog(" roots: " + JSON.stringify(rootFileNames)); writeLog(" options: " + JSON.stringify(compilerOptions)); + if (projectReferences) + writeLog(" projectReferences: " + JSON.stringify(projectReferences)); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; @@ -113034,10 +116083,10 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); // Update extended config file watch - watchExtendedConfigFiles(); + updateExtendedConfigFilesWatches(toPath(configFileName), compilerOptions, watchOptions, ts.WatchType.ExtendedConfigFile); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, /*extendedConfigCache*/ undefined, watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; @@ -113049,6 +116098,56 @@ var ts; canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(configFileParseResult.raw); hasChangedConfigFileParsingErrors = true; } + function getParsedCommandLine(configFileName) { + var configPath = toPath(configFileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) { + if (!config.reloadLevel) + return config.parsedCommandLine; + // With host implementing getParsedCommandLine we cant just update file names + if (config.parsedCommandLine && config.reloadLevel === ts.ConfigFileProgramReloadLevel.Partial && !host.getParsedCommandLine) { + writeLog("Reloading new file names and options"); + var fileNames = ts.getFileNamesFromConfigSpecs(config.parsedCommandLine.options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost); + config.parsedCommandLine = __assign(__assign({}, config.parsedCommandLine), { fileNames: fileNames }); + config.reloadLevel = undefined; + return config.parsedCommandLine; + } + } + writeLog("Loading config file: " + configFileName); + var parsedCommandLine = host.getParsedCommandLine ? + host.getParsedCommandLine(configFileName) : + getParsedCommandLineFromConfigFileHost(configFileName); + if (config) { + config.parsedCommandLine = parsedCommandLine; + config.reloadLevel = undefined; + } + else { + (parsedConfigs || (parsedConfigs = new ts.Map())).set(configPath, config = { parsedCommandLine: parsedCommandLine }); + } + watchReferencedProject(configFileName, configPath, config); + return parsedCommandLine; + } + function getParsedCommandLineFromConfigFileHost(configFileName) { + // Ignore the file absent errors + var onUnRecoverableConfigFileDiagnostic = parseConfigFileHost.onUnRecoverableConfigFileDiagnostic; + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop; + var parsedCommandLine = ts.getParsedCommandLineOfConfigFile(configFileName, + /*optionsToExtend*/ undefined, parseConfigFileHost, extendedConfigCache || (extendedConfigCache = new ts.Map()), watchOptionsToExtend); + parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = onUnRecoverableConfigFileDiagnostic; + return parsedCommandLine; + } + function onReleaseParsedCommandLine(fileName) { + var _a; + var path = toPath(fileName); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(path); + if (!config) + return; + parsedConfigs.delete(path); + if (config.watchedDirectories) + ts.clearMap(config.watchedDirectories, ts.closeFileWatcherOf); + (_a = config.watcher) === null || _a === void 0 ? void 0 : _a.close(); + ts.clearSharedExtendedConfigFileWatcher(path, sharedExtendedConfigFileWatchers); + } function watchFilePath(path, file, callback, pollingInterval, options, watchType) { return watchFile(file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options, watchType); } @@ -113058,7 +116157,6 @@ var ts; if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) { resolutionCache.invalidateResolutionOfFile(path); } - resolutionCache.removeResolutionsFromProjectReferenceRedirects(path); nextSourceFileVersion(path); // Update the program scheduleProgramUpdate(); @@ -113069,7 +116167,10 @@ var ts; } } function watchMissingFilePath(missingFilePath) { - return watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); + // If watching missing referenced config file, we are already watching it so no need for separate watcher + return (parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.has(missingFilePath)) ? + ts.noopFileWatcher : + watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile); } function onMissingFileChange(fileName, eventKind, missingFilePath) { updateCachedSystemWithFile(fileName, missingFilePath, eventKind); @@ -113106,10 +116207,11 @@ var ts; configFileName: configFileName, extraFileExtensions: extraFileExtensions, options: compilerOptions, - program: getCurrentBuilderProgram(), + program: getCurrentBuilderProgram() || rootFileNames, currentDirectory: currentDirectory, useCaseSensitiveFileNames: useCaseSensitiveFileNames, - writeLog: writeLog + writeLog: writeLog, + toPath: toPath, })) return; // Reload is pending, do the reload @@ -113120,18 +116222,87 @@ var ts; } }, flags, watchOptions, ts.WatchType.WildcardDirectory); } - function watchExtendedConfigFiles() { - var _a; - // Update the extended config files watcher - ts.mutateMap(extendedConfigFilesMap || (extendedConfigFilesMap = new ts.Map()), ts.arrayToMap(((_a = compilerOptions.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath), { - // Watch the extended config files - createNewValue: watchExtendedConfigFile, - // Config files that are no longer extended should no longer be watched. - onDeleteValue: ts.closeFileWatcher - }); + function updateExtendedConfigFilesWatches(forProjectPath, options, watchOptions, watchType) { + ts.updateSharedExtendedConfigFileWatcher(forProjectPath, options, sharedExtendedConfigFileWatchers || (sharedExtendedConfigFileWatchers = new ts.Map()), function (extendedConfigFileName, extendedConfigFilePath) { return watchFile(extendedConfigFileName, function (_fileName, eventKind) { + var _a; + updateCachedSystemWithFile(extendedConfigFileName, extendedConfigFilePath, eventKind); + // Update extended config cache + if (extendedConfigCache) + ts.cleanExtendedConfigCache(extendedConfigCache, extendedConfigFilePath, toPath); + // Update projects + var projects = (_a = sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects; + // If there are no referenced projects this extended config file watcher depend on ignore + if (!(projects === null || projects === void 0 ? void 0 : projects.size)) + return; + projects.forEach(function (projectPath) { + if (toPath(configFileName) === projectPath) { + // If this is the config file of the project, reload completely + reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + } + else { + // Reload config for the referenced projects and remove the resolutions from referenced projects since the config file changed + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(projectPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(projectPath); + } + scheduleProgramUpdate(); + }); + }, ts.PollingInterval.High, watchOptions, watchType); }, toPath); } - function watchExtendedConfigFile(extendedConfigFile) { - return watchFile(extendedConfigFile, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ExtendedConfigFile); + function watchReferencedProject(configFileName, configPath, commandLine) { + var _a, _b, _c, _d, _e; + // Watch file + commandLine.watcher || (commandLine.watcher = watchFile(configFileName, function (_fileName, eventKind) { + updateCachedSystemWithFile(configFileName, configPath, eventKind); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (config) + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Full; + resolutionCache.removeResolutionsFromProjectReferenceRedirects(configPath); + scheduleProgramUpdate(); + }, ts.PollingInterval.High, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.ConfigFileOfReferencedProject)); + // Watch Wild card + if ((_b = commandLine.parsedCommandLine) === null || _b === void 0 ? void 0 : _b.wildcardDirectories) { + ts.updateWatchingWildcardDirectories(commandLine.watchedDirectories || (commandLine.watchedDirectories = new ts.Map()), new ts.Map(ts.getEntries((_c = commandLine.parsedCommandLine) === null || _c === void 0 ? void 0 : _c.wildcardDirectories)), function (directory, flags) { + var _a; + return watchDirectory(directory, function (fileOrDirectory) { + var fileOrDirectoryPath = toPath(fileOrDirectory); + // Since the file existence changed, update the sourceFiles cache + if (cachedDirectoryStructureHost) { + cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + } + nextSourceFileVersion(fileOrDirectoryPath); + var config = parsedConfigs === null || parsedConfigs === void 0 ? void 0 : parsedConfigs.get(configPath); + if (!(config === null || config === void 0 ? void 0 : config.parsedCommandLine)) + return; + if (ts.isIgnoredFileFromWildCardWatching({ + watchedDirPath: toPath(directory), + fileOrDirectory: fileOrDirectory, + fileOrDirectoryPath: fileOrDirectoryPath, + configFileName: configFileName, + options: config.parsedCommandLine.options, + program: config.parsedCommandLine.fileNames, + currentDirectory: currentDirectory, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + writeLog: writeLog, + toPath: toPath, + })) + return; + // Reload is pending, do the reload + if (config.reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) { + config.reloadLevel = ts.ConfigFileProgramReloadLevel.Partial; + // Schedule Update the program + scheduleProgramUpdate(); + } + }, flags, ((_a = commandLine.parsedCommandLine) === null || _a === void 0 ? void 0 : _a.watchOptions) || watchOptions, ts.WatchType.WildcardDirectoryOfReferencedProject); + }); + } + else if (commandLine.watchedDirectories) { + ts.clearMap(commandLine.watchedDirectories, ts.closeFileWatcherOf); + commandLine.watchedDirectories = undefined; + } + // Watch extended config files + updateExtendedConfigFilesWatches(configPath, (_d = commandLine.parsedCommandLine) === null || _d === void 0 ? void 0 : _d.options, ((_e = commandLine.parsedCommandLine) === null || _e === void 0 ? void 0 : _e.watchOptions) || watchOptions, ts.WatchType.ExtendedConfigOfReferencedProject); } } ts.createWatchProgram = createWatchProgram; @@ -113291,12 +116462,19 @@ var ts; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); 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); }; } + if (!compilerHost.resolveTypeReferenceDirectives) { + var loader_4 = function (moduleName, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective; }; + compilerHost.resolveTypeReferenceDirectives = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { + return ts.loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_4); + }; + } var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog; var state = { host: host, @@ -113321,6 +116499,7 @@ var ts; projectErrorsReported: new ts.Map(), compilerHost: compilerHost, moduleResolutionCache: moduleResolutionCache, + typeReferenceDirectiveResolutionCache: typeReferenceDirectiveResolutionCache, // Mutable state buildOrder: undefined, readFileWithCache: function (f) { return host.readFile(f); }, @@ -113359,6 +116538,10 @@ var ts; function isParsedCommandLine(entry) { return !!entry.options; } + function getCachedParsedConfigFile(state, configFilePath) { + var value = state.configFileCache.get(configFilePath); + return value && isParsedCommandLine(value) ? value : undefined; + } function parseConfigFile(state, configFileName, configFilePath) { var configFileCache = state.configFileCache; var value = configFileCache.get(configFilePath); @@ -113504,7 +116687,7 @@ var ts; function disableCache(state) { if (!state.cache) return; - var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache; + var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache, typeReferenceDirectiveResolutionCache = state.typeReferenceDirectiveResolutionCache; host.readFile = cache.originalReadFile; host.fileExists = cache.originalFileExists; host.directoryExists = cache.originalDirectoryExists; @@ -113513,10 +116696,8 @@ var ts; compilerHost.getSourceFile = cache.originalGetSourceFile; state.readFileWithCache = cache.originalReadFileWithCache; extendedConfigCache.clear(); - if (moduleResolutionCache) { - moduleResolutionCache.directoryToModuleNameMap.clear(); - moduleResolutionCache.moduleNameToDirectoryMap.clear(); - } + moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache === null || typeReferenceDirectiveResolutionCache === void 0 ? void 0 : typeReferenceDirectiveResolutionCache.clear(); state.cache = undefined; } function clearProjectStatus(state, resolved) { @@ -113683,6 +116864,7 @@ var ts; return withProgramOrUndefined(action) || ts.emptyArray; } function createProgram() { + var _a, _b; ts.Debug.assert(program === undefined); if (state.options.dry) { reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project); @@ -113702,7 +116884,8 @@ var ts; var host = state.host, compilerHost = state.compilerHost; state.projectCompilerOptions = config.options; // Update module resolution cache if needed - updateModuleResolutionCache(state, project, config); + (_a = state.moduleResolutionCache) === null || _a === void 0 ? void 0 : _a.update(config.options); + (_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); if (state.watch) { @@ -113877,7 +117060,7 @@ var ts; emitBundle(writeFile, customTransformers); break; case BuildStep.BuildInvalidatedProjectOfBundle: - ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken); + ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken, writeFile, customTransformers); step = BuildStep.Done; break; case BuildStep.QueueReferencingProjects: @@ -114019,34 +117202,9 @@ var ts; afterProgramDone(state, program, config); return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects }; } - function updateModuleResolutionCache(state, proj, config) { - if (!state.moduleResolutionCache) - return; - // Update module resolution cache if needed - var moduleResolutionCache = state.moduleResolutionCache; - var projPath = toPath(state, proj); - if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) { - // The own map will be for projectCompilerOptions - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0); - moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap); - moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap); - } - else { - // Set correct own map - ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0); - var ref = { - sourceFile: config.options.configFile, - commandLine: config - }; - moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); - } - moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options); - } function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) { // Check tsconfig time - var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime; + var tsconfigTime = ts.getModifiedTime(state.host, configFile); if (oldestOutputFileTime < tsconfigTime) { return { type: ts.UpToDateStatusType.OutOfDateWithSelf, @@ -114056,6 +117214,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { + var force = !!state.options.force; var newestInputFileName = undefined; var newestInputFileTime = minimumDate; var host = state.host; @@ -114068,10 +117227,13 @@ var ts; reason: inputFile + " does not exist" }; } - var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime; - if (inputTime > newestInputFileTime) { - newestInputFileName = inputFile; - newestInputFileTime = inputTime; + if (!force) { + var inputTime = ts.getModifiedTime(host, inputFile); + host.getModifiedTime(inputFile); + if (inputTime > newestInputFileTime) { + newestInputFileName = inputFile; + newestInputFileTime = inputTime; + } } } // Container if no files are specified in the project @@ -114090,36 +117252,38 @@ var ts; var missingOutputFileName; var newestDeclarationFileContentChangedTime = minimumDate; var isOutOfDateWithInputs = false; - for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { - var output = outputs_1[_b]; - // Output is missing; can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (!host.fileExists(output)) { - missingOutputFileName = output; - break; - } - var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - if (outputTime < oldestOutputFileTime) { - oldestOutputFileTime = outputTime; - oldestOutputFileName = output; - } - // If an output is older than the newest input, we can stop checking - // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status - if (outputTime < newestInputFileTime) { - isOutOfDateWithInputs = true; - break; - } - if (outputTime > newestOutputFileTime) { - newestOutputFileTime = outputTime; - newestOutputFileName = output; - } - // Keep track of when the most recent time a .d.ts file was changed. - // In addition to file timestamps, we also keep track of when a .d.ts file - // had its file touched but not had its contents changed - this allows us - // to skip a downstream typecheck - if (isDeclarationFile(output)) { - var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime; - newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + if (!force) { + for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) { + var output = outputs_1[_b]; + // Output is missing; can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (!host.fileExists(output)) { + missingOutputFileName = output; + break; + } + var outputTime = ts.getModifiedTime(host, output); + if (outputTime < oldestOutputFileTime) { + oldestOutputFileTime = outputTime; + oldestOutputFileName = output; + } + // If an output is older than the newest input, we can stop checking + // Don't immediately return because we can still be upstream-blocked, which is a higher-priority status + if (outputTime < newestInputFileTime) { + isOutOfDateWithInputs = true; + break; + } + if (outputTime > newestOutputFileTime) { + newestOutputFileTime = outputTime; + newestOutputFileName = output; + } + // Keep track of when the most recent time a .d.ts file was changed. + // In addition to file timestamps, we also keep track of when a .d.ts file + // had its file touched but not had its contents changed - this allows us + // to skip a downstream typecheck + if (isDeclarationFile(output)) { + var outputModifiedTime = ts.getModifiedTime(host, output); + newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime); + } } } var pseudoUpToDate = false; @@ -114155,7 +117319,8 @@ var ts; }; } // Check oldest output file name only if there is no missing output file name - if (!missingOutputFileName) { + // (a check we will have skipped if this is a forced build) + if (!force && !missingOutputFileName) { // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { @@ -114201,7 +117366,7 @@ var ts; if (extendedConfigStatus) return extendedConfigStatus; } - if (!state.buildInfoChecked.has(resolvedPath)) { + if (!force && !state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { @@ -114261,7 +117426,7 @@ var ts; reportStatus(state, verboseMessage, proj.options.configFilePath); } if (isDeclarationFile(file)) { - priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime); + priorNewestUpdateTime = newer(priorNewestUpdateTime, ts.getModifiedTime(host, file)); } host.setModifiedTime(file, now); } @@ -114343,7 +117508,7 @@ var ts; } } } - function build(state, project, cancellationToken, onlyReferences) { + function build(state, project, cancellationToken, writeFile, getCustomTransformers, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; @@ -114355,7 +117520,7 @@ var ts; if (!invalidatedProject) break; reportQueue = false; - invalidatedProject.done(cancellationToken); + invalidatedProject.done(cancellationToken, writeFile, getCustomTransformers === null || getCustomTransformers === void 0 ? void 0 : getCustomTransformers(invalidatedProject.project)); if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; } @@ -114390,8 +117555,14 @@ var ts; continue; } var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames()); + if (!outputs.length) + continue; + var inputFileNames = new ts.Set(parsed.fileNames.map(function (f) { return toPath(state, f); })); for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) { var output = outputs_3[_a]; + // If output name is same as input file name, do not delete and ignore the error + if (inputFileNames.has(toPath(state, output))) + continue; if (host.fileExists(output)) { if (filesToDelete) { filesToDelete.push(output); @@ -114467,7 +117638,7 @@ var ts; }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved)); } function watchExtendedConfigFiles(state, resolvedPath, parsed) { - ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { + ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed === null || parsed === void 0 ? void 0 : parsed.options, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () { var _a; return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) { return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full); @@ -114478,6 +117649,7 @@ var ts; if (!state.watch) return; ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), new ts.Map(ts.getEntries(parsed.wildcardDirectories)), function (dir, flags) { return state.watchDirectory(dir, function (fileOrDirectory) { + var _a; if (ts.isIgnoredFileFromWildCardWatching({ watchedDirPath: toPath(state, dir), fileOrDirectory: fileOrDirectory, @@ -114485,9 +117657,10 @@ var ts; configFileName: resolved, currentDirectory: state.currentDirectory, options: parsed.options, - program: state.builderPrograms.get(resolvedPath), + program: state.builderPrograms.get(resolvedPath) || ((_a = getCachedParsedConfigFile(state, resolvedPath)) === null || _a === void 0 ? void 0 : _a.fileNames), useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames, - writeLog: function (s) { return state.writeLog(s); } + writeLog: function (s) { return state.writeLog(s); }, + toPath: function (fileName) { return toPath(state, fileName); } })) return; invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial); @@ -114522,19 +117695,16 @@ var ts; } function stopWatching(state) { ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher); - ts.clearMap(state.allWatchedExtendedConfigFiles, function (watcher) { - watcher.projects.clear(); - watcher.close(); - }); + ts.clearMap(state.allWatchedExtendedConfigFiles, ts.closeFileWatcherOf); ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); }); ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); }); } function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) { var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions); return { - build: function (project, cancellationToken) { return build(state, project, cancellationToken); }, + build: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers); }, clean: function (project) { return clean(state, project); }, - buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, /*onlyReferences*/ true); }, + buildReferences: function (project, cancellationToken, writeFile, getCustomTransformers) { return build(state, project, cancellationToken, writeFile, getCustomTransformers, /*onlyReferences*/ true); }, cleanReferences: function (project) { return clean(state, project, /*onlyReferences*/ true); }, getNextInvalidatedProject: function (cancellationToken) { setupInitialBuild(state, cancellationToken); @@ -114624,6 +117794,9 @@ var ts; } } function reportUpToDateStatus(state, configFileName, status) { + if (state.options.force && (status.type === ts.UpToDateStatusType.UpToDate || status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes)) { + return reportStatus(state, ts.Diagnostics.Project_0_is_being_forcibly_rebuilt, relName(state, configFileName)); + } switch (status.type) { case ts.UpToDateStatusType.OutOfDateWithSelf: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relName(state, configFileName), relName(state, status.outOfDateOutputFileName), relName(state, status.newerInputFileName)); @@ -115173,6 +118346,9 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["enumMemberName"] = 19] = "enumMemberName"; SymbolDisplayPartKind[SymbolDisplayPartKind["functionName"] = 20] = "functionName"; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; + SymbolDisplayPartKind[SymbolDisplayPartKind["link"] = 22] = "link"; + SymbolDisplayPartKind[SymbolDisplayPartKind["linkName"] = 23] = "linkName"; + SymbolDisplayPartKind[SymbolDisplayPartKind["linkText"] = 24] = "linkText"; })(SymbolDisplayPartKind = ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); var OutliningSpanKind; (function (OutliningSpanKind) { @@ -115283,6 +118459,12 @@ var ts; ScriptElementKind["jsxAttribute"] = "JSX attribute"; /** String literal */ ScriptElementKind["string"] = "string"; + /** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */ + ScriptElementKind["link"] = "link"; + /** Jsdoc @link: in `{@link C link text}`, the entity name "C" */ + ScriptElementKind["linkName"] = "link name"; + /** Jsdoc @link: in `{@link C link text}`, the link text "link text" */ + ScriptElementKind["linkText"] = "link text"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { @@ -115375,37 +118557,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 287 /* CatchClause */: - case 280 /* JsxAttribute */: + case 161 /* Parameter */: + case 199 /* BindingElement */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 289 /* PropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 288 /* CatchClause */: + case 281 /* JsxAttribute */: return 1 /* Value */; - case 159 /* TypeParameter */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 177 /* TypeLiteral */: + case 160 /* TypeParameter */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 178 /* TypeLiteral */: return 2 /* Type */; - case 331 /* JSDocTypedefTag */: + case 335 /* 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 291 /* EnumMember */: - case 252 /* ClassDeclaration */: + case 292 /* EnumMember */: + case 253 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -115415,16 +118597,16 @@ var ts; else { return 4 /* Namespace */; } - case 255 /* EnumDeclaration */: - case 264 /* NamedImports */: - case 265 /* ImportSpecifier */: - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 266 /* ExportAssignment */: - case 267 /* ExportDeclaration */: + case 256 /* EnumDeclaration */: + case 265 /* NamedImports */: + case 266 /* ImportSpecifier */: + case 261 /* ImportEqualsDeclaration */: + case 262 /* ImportDeclaration */: + case 267 /* ExportAssignment */: + case 268 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 297 /* SourceFile */: + case 298 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; @@ -115432,13 +118614,13 @@ var ts; ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 298 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 266 /* ExportAssignment */ - || node.parent.kind === 272 /* ExternalModuleReference */ - || node.parent.kind === 265 /* ImportSpecifier */ - || node.parent.kind === 262 /* ImportClause */ + else if (node.parent.kind === 267 /* ExportAssignment */ + || node.parent.kind === 273 /* ExternalModuleReference */ + || node.parent.kind === 266 /* ImportSpecifier */ + || node.parent.kind === 263 /* ImportClause */ || ts.isImportEqualsDeclaration(node.parent) && node === node.parent.name) { return 7 /* All */; } @@ -115448,7 +118630,7 @@ var ts; else if (ts.isDeclarationName(node)) { return getMeaningFromDeclaration(node.parent); } - else if (ts.isEntityName(node) && ts.isJSDocNameReference(node.parent)) { + else if (ts.isEntityName(node) && (ts.isJSDocNameReference(node.parent) || ts.isJSDocLink(node.parent))) { return 7 /* All */; } else if (isTypeReference(node)) { @@ -115474,11 +118656,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 157 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 260 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 158 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 261 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 157 /* QualifiedName */) { + while (node.parent.kind === 158 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -115490,27 +118672,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 157 /* QualifiedName */) { - while (root.parent && root.parent.kind === 157 /* QualifiedName */) { + if (root.parent.kind === 158 /* QualifiedName */) { + while (root.parent && root.parent.kind === 158 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 173 /* TypeReference */ && !isLastClause; + return root.parent.kind === 174 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 201 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 201 /* PropertyAccessExpression */) { + if (root.parent.kind === 202 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 202 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 223 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 286 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 224 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 287 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 252 /* ClassDeclaration */ && root.parent.parent.token === 116 /* ImplementsKeyword */) || - (decl.kind === 253 /* InterfaceDeclaration */ && root.parent.parent.token === 93 /* ExtendsKeyword */); + return (decl.kind === 253 /* ClassDeclaration */ && root.parent.parent.token === 116 /* ImplementsKeyword */) || + (decl.kind === 254 /* InterfaceDeclaration */ && root.parent.parent.token === 93 /* ExtendsKeyword */); } return false; } @@ -115521,15 +118703,15 @@ var ts; switch (node.kind) { case 107 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 187 /* ThisType */: + case 188 /* ThisType */: return true; } switch (node.parent.kind) { - case 173 /* TypeReference */: + case 174 /* TypeReference */: return true; - case 195 /* ImportType */: + case 196 /* ImportType */: return !node.parent.isTypeOf; - case 223 /* ExpressionWithTypeArguments */: + case 224 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -115596,7 +118778,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 245 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 246 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -115657,22 +118839,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 288 /* PropertyAssignment */: - case 291 /* EnumMember */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 256 /* ModuleDeclaration */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 289 /* PropertyAssignment */: + case 292 /* EnumMember */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 257 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 158 /* ComputedPropertyName */: + case 159 /* ComputedPropertyName */: return true; - case 191 /* LiteralType */: - return node.parent.parent.kind === 189 /* IndexedAccessType */; + case 192 /* LiteralType */: + return node.parent.parent.kind === 190 /* IndexedAccessType */; default: return false; } @@ -115696,17 +118878,17 @@ var ts; return undefined; } switch (node.kind) { - case 297 /* SourceFile */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: + case 298 /* SourceFile */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 256 /* EnumDeclaration */: + case 257 /* ModuleDeclaration */: return node; } } @@ -115714,54 +118896,54 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 297 /* SourceFile */: + case 298 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: return "class" /* classElement */; - case 253 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 254 /* TypeAliasDeclaration */: - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: + case 254 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 255 /* TypeAliasDeclaration */: + case 328 /* JSDocCallbackTag */: + case 335 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 255 /* EnumDeclaration */: return "enum" /* enumElement */; - case 249 /* VariableDeclaration */: + case 256 /* EnumDeclaration */: return "enum" /* enumElement */; + case 250 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 198 /* BindingElement */: + case 199 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: return "function" /* functionElement */; - case 167 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 168 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 168 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 169 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: var initializer = node.initializer; return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 289 /* ShorthandPropertyAssignment */: - case 290 /* SpreadAssignment */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 290 /* ShorthandPropertyAssignment */: + case 291 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 171 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 170 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 169 /* CallSignature */: return "call" /* callSignatureElement */; - case 166 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 159 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 291 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 160 /* Parameter */: return ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: - case 263 /* NamespaceImport */: - case 269 /* NamespaceExport */: + case 172 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 171 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 170 /* CallSignature */: return "call" /* callSignatureElement */; + case 167 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 160 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 292 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 161 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 261 /* ImportEqualsDeclaration */: + case 266 /* ImportSpecifier */: + case 271 /* ExportSpecifier */: + case 264 /* NamespaceImport */: + case 270 /* NamespaceExport */: return "alias" /* alias */; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -115790,7 +118972,7 @@ var ts; } case 78 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 266 /* ExportAssignment */: + case 267 /* 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; @@ -115813,7 +118995,7 @@ var ts; return true; case 78 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 160 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 161 /* Parameter */; default: return false; } @@ -115878,42 +119060,42 @@ var ts; return false; } switch (n.kind) { - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 200 /* ObjectLiteralExpression */: - case 196 /* ObjectBindingPattern */: - case 177 /* TypeLiteral */: - case 230 /* Block */: - case 257 /* ModuleBlock */: - case 258 /* CaseBlock */: - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 256 /* EnumDeclaration */: + case 201 /* ObjectLiteralExpression */: + case 197 /* ObjectBindingPattern */: + case 178 /* TypeLiteral */: + case 231 /* Block */: + case 258 /* ModuleBlock */: + case 259 /* CaseBlock */: + case 265 /* NamedImports */: + case 269 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 287 /* CatchClause */: + case 288 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 204 /* NewExpression */: + case 205 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 203 /* CallExpression */: - case 207 /* ParenthesizedExpression */: - case 186 /* ParenthesizedType */: + case 204 /* CallExpression */: + case 208 /* ParenthesizedExpression */: + case 187 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 174 /* FunctionType */: - case 175 /* ConstructorType */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 170 /* ConstructSignature */: - case 169 /* CallSignature */: - case 209 /* ArrowFunction */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 171 /* ConstructSignature */: + case 170 /* CallSignature */: + case 210 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -115923,65 +119105,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 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 234 /* IfStatement */: + case 235 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 199 /* ArrayLiteralExpression */: - case 197 /* ArrayBindingPattern */: - case 202 /* ElementAccessExpression */: - case 158 /* ComputedPropertyName */: - case 179 /* TupleType */: + case 200 /* ArrayLiteralExpression */: + case 198 /* ArrayBindingPattern */: + case 203 /* ElementAccessExpression */: + case 159 /* ComputedPropertyName */: + case 180 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 171 /* IndexSignature */: + case 172 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 237 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 235 /* DoStatement */: + case 236 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 114 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 176 /* TypeQuery */: + case 177 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 211 /* TypeOfExpression */: - case 210 /* DeleteExpression */: - case 212 /* VoidExpression */: - case 219 /* YieldExpression */: - case 220 /* SpreadElement */: + case 212 /* TypeOfExpression */: + case 211 /* DeleteExpression */: + case 213 /* VoidExpression */: + case 220 /* YieldExpression */: + case 221 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 218 /* TemplateExpression */: + case 219 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 228 /* TemplateSpan */: + case 229 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 267 /* ExportDeclaration */: - case 261 /* ImportDeclaration */: + case 268 /* ExportDeclaration */: + case 262 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 217 /* ConditionalExpression */: + case 218 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -116107,11 +119289,11 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: return getAdjustedLocationForClass(node); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: return getAdjustedLocationForFunction(node); } } @@ -116371,7 +119553,7 @@ var ts; // for (... /**/in [|name|]) // for (... /**/of [|name|]) if (node.kind === 100 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 156 /* OfKeyword */ && ts.isForOfStatement(parent)) { + node.kind === 157 /* OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -116440,6 +119622,21 @@ var ts; return current; } } + /** + * Returns the first token where position is in [start, end), + * excluding `JsxText` tokens containing only whitespace. + */ + function findFirstNonJsxWhitespaceToken(sourceFile, position) { + var tokenAtPosition = getTokenAtPosition(sourceFile, position); + while (isWhiteSpaceOnlyJsxText(tokenAtPosition)) { + var nextToken = findNextToken(tokenAtPosition, tokenAtPosition.parent, sourceFile); + if (!nextToken) + return; + tokenAtPosition = nextToken; + } + return tokenAtPosition; + } + ts.findFirstNonJsxWhitespaceToken = findFirstNonJsxWhitespaceToken; /** * The token on the left of the position is the token that strictly includes the position * or sits to the left of the cursor if it is on a boundary. For example @@ -116526,7 +119723,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 297 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 298 /* 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. @@ -116599,17 +119796,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 283 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 284 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 283 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 284 /* JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 276 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 277 /* JsxClosingElement */) { return true; } return false; @@ -116640,7 +119837,7 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 274 /* JsxSelfClosingElement */ && node.kind <= 283 /* JsxExpression */ + if (node.kind >= 275 /* JsxSelfClosingElement */ && node.kind <= 284 /* JsxExpression */ || node.kind === 11 /* JsxText */ || node.kind === 29 /* LessThanToken */ || node.kind === 31 /* GreaterThanToken */ @@ -116650,7 +119847,7 @@ var ts; || node.kind === 43 /* SlashToken */) { node = node.parent; } - else if (node.kind === 273 /* JsxElement */) { + else if (node.kind === 274 /* JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -116858,16 +120055,16 @@ var ts; result.push("deprecated" /* deprecatedModifier */); if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); - if (node.kind === 266 /* ExportAssignment */) + if (node.kind === 267 /* ExportAssignment */) result.push("export" /* exportedModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 173 /* TypeReference */ || node.kind === 203 /* CallExpression */) { + if (node.kind === 174 /* TypeReference */ || node.kind === 204 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 252 /* ClassDeclaration */ || node.kind === 253 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 253 /* ClassDeclaration */ || node.kind === 254 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -116912,18 +120109,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 199 /* ArrayLiteralExpression */ || - node.kind === 200 /* ObjectLiteralExpression */) { + if (node.kind === 200 /* ArrayLiteralExpression */ || + node.kind === 201 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 216 /* BinaryExpression */ && + if (node.parent.kind === 217 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 239 /* ForOfStatement */ && + if (node.parent.kind === 240 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -116931,7 +120128,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 288 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 289 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -117051,7 +120248,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 158 /* ComputedPropertyName */ + return name.kind === 159 /* 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); @@ -117070,7 +120267,7 @@ var ts; } ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules; function createModuleSpecifierResolutionHost(program, host) { - // Mix in `getProbableSymlinks` from Program when host doesn't have it + // Mix in `getSymlinkCache` from Program when host doesn't have it // in order for non-Project hosts to have a symlinks cache. return { fileExists: function (fileName) { return program.fileExists(fileName); }, @@ -117078,6 +120275,7 @@ var ts; readFile: ts.maybeBind(host, host.readFile), useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache, + getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache), getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), getSourceFiles: function () { return program.getSourceFiles(); }, redirectTargetsMap: program.redirectTargetsMap, @@ -117152,6 +120350,13 @@ var ts; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; + function isModuleSpecifierLike(node) { + return ts.isStringLiteralLike(node) && (ts.isExternalModuleReference(node.parent) || + ts.isImportDeclaration(node.parent) || + ts.isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false) && node.parent.arguments[0] === node || + ts.isImportCall(node.parent) && node.parent.arguments[0] === node); + } + ts.isModuleSpecifierLike = isModuleSpecifierLike; function isObjectBindingElementWithoutPropertyName(bindingElement) { return ts.isBindingElement(bindingElement) && ts.isObjectBindingPattern(bindingElement.parent) && @@ -117185,7 +120390,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 232 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 233 /* 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) { @@ -117263,7 +120468,7 @@ var ts; // Display-part writer helpers // #region function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 160 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 161 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -117426,6 +120631,14 @@ var ts; return displayPart(ts.tokenToString(kind), ts.SymbolDisplayPartKind.operator); } ts.operatorPart = operatorPart; + function parameterNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.parameterName); + } + ts.parameterNamePart = parameterNamePart; + function propertyNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.propertyName); + } + ts.propertyNamePart = propertyNamePart; function textOrKeywordPart(text) { var kind = ts.stringToToken(text); return kind === undefined @@ -117437,6 +120650,58 @@ var ts; return displayPart(text, ts.SymbolDisplayPartKind.text); } ts.textPart = textPart; + function typeAliasNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.aliasName); + } + ts.typeAliasNamePart = typeAliasNamePart; + function typeParameterNamePart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.typeParameterName); + } + ts.typeParameterNamePart = typeParameterNamePart; + function linkTextPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.linkText); + } + ts.linkTextPart = linkTextPart; + function linkNamePart(name, target) { + return { + text: ts.getTextOfNode(name), + kind: ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.linkName], + target: { + fileName: ts.getSourceFileOfNode(target).fileName, + textSpan: createTextSpanFromNode(target), + }, + }; + } + ts.linkNamePart = linkNamePart; + function linkPart(text) { + return displayPart(text, ts.SymbolDisplayPartKind.link); + } + ts.linkPart = linkPart; + function buildLinkParts(link, checker) { + var _a; + var parts = [linkPart("{@link ")]; + if (!link.name) { + if (link.text) { + parts.push(linkTextPart(link.text)); + } + } + else { + var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name); + 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)); + } + } + else { + parts.push(linkTextPart(ts.getTextOfNode(link.name) + link.text)); + } + } + parts.push(linkPart("}")); + return parts; + } + ts.buildLinkParts = buildLinkParts; var carriageReturnLineFeed = "\r\n"; /** * The default is CRLF. @@ -117722,21 +120987,23 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + || ts.isObjectLiteralExpression(expression) + || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } ts.needsParentheses = needsParentheses; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 204 /* NewExpression */: + case 205 /* NewExpression */: return checker.getContextualType(parent); - case 216 /* BinaryExpression */: { + case 217 /* 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 284 /* CaseClause */: + case 285 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -117766,8 +121033,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 218 /* TemplateExpression */: - case 205 /* TaggedTemplateExpression */: + case 219 /* TemplateExpression */: + case 206 /* TaggedTemplateExpression */: return true; default: return false; @@ -117800,41 +121067,41 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 169 /* CallSignature */ - || kind === 170 /* ConstructSignature */ - || kind === 171 /* IndexSignature */ - || kind === 162 /* PropertySignature */ - || kind === 164 /* MethodSignature */; + return kind === 170 /* CallSignature */ + || kind === 171 /* ConstructSignature */ + || kind === 172 /* IndexSignature */ + || kind === 163 /* PropertySignature */ + || kind === 165 /* MethodSignature */; } ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 251 /* FunctionDeclaration */ - || kind === 166 /* Constructor */ - || kind === 165 /* MethodDeclaration */ - || kind === 167 /* GetAccessor */ - || kind === 168 /* SetAccessor */; + return kind === 252 /* FunctionDeclaration */ + || kind === 167 /* Constructor */ + || kind === 166 /* MethodDeclaration */ + || kind === 168 /* GetAccessor */ + || kind === 169 /* SetAccessor */; } ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 256 /* ModuleDeclaration */; + return kind === 257 /* ModuleDeclaration */; } ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 232 /* VariableStatement */ - || kind === 233 /* ExpressionStatement */ - || kind === 235 /* DoStatement */ - || kind === 240 /* ContinueStatement */ - || kind === 241 /* BreakStatement */ - || kind === 242 /* ReturnStatement */ - || kind === 246 /* ThrowStatement */ - || kind === 248 /* DebuggerStatement */ - || kind === 163 /* PropertyDeclaration */ - || kind === 254 /* TypeAliasDeclaration */ - || kind === 261 /* ImportDeclaration */ - || kind === 260 /* ImportEqualsDeclaration */ - || kind === 267 /* ExportDeclaration */ - || kind === 259 /* NamespaceExportDeclaration */ - || kind === 266 /* ExportAssignment */; + return kind === 233 /* VariableStatement */ + || kind === 234 /* ExpressionStatement */ + || kind === 236 /* DoStatement */ + || kind === 241 /* ContinueStatement */ + || kind === 242 /* BreakStatement */ + || kind === 243 /* ReturnStatement */ + || kind === 247 /* ThrowStatement */ + || kind === 249 /* DebuggerStatement */ + || kind === 164 /* PropertyDeclaration */ + || kind === 255 /* TypeAliasDeclaration */ + || kind === 262 /* ImportDeclaration */ + || kind === 261 /* ImportEqualsDeclaration */ + || kind === 268 /* ExportDeclaration */ + || kind === 260 /* NamespaceExportDeclaration */ + || kind === 267 /* ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); @@ -117864,7 +121131,7 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 235 /* DoStatement */) { + if (node.kind === 236 /* DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); @@ -118038,6 +121305,94 @@ var ts; } } ts.createPackageJsonInfo = createPackageJsonInfo; + function createPackageJsonImportFilter(fromFile, host) { + var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName) || packageJson.has(ts.getTypesPackageName(packageName))) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost) { + if (!packageJsons.length || !moduleSymbol.valueDeclaration) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, moduleSpecifierResolutionHost); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, moduleSpecifierResolutionHost) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, moduleSpecifierResolutionHost); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, moduleSpecifierResolutionHost) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } + ts.createPackageJsonImportFilter = createPackageJsonImportFilter; function tryParseJson(text) { try { return JSON.parse(text); @@ -118180,6 +121535,184 @@ var ts; return ts.isInJSFile(declaration) || !ts.findAncestor(declaration, ts.isGlobalScopeAugmentation); } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; + var ImportKind; + (function (ImportKind) { + ImportKind[ImportKind["Named"] = 0] = "Named"; + ImportKind[ImportKind["Default"] = 1] = "Default"; + ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; + ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; + })(ImportKind = ts.ImportKind || (ts.ImportKind = {})); + var ExportKind; + (function (ExportKind) { + ExportKind[ExportKind["Named"] = 0] = "Named"; + ExportKind[ExportKind["Default"] = 1] = "Default"; + ExportKind[ExportKind["ExportEquals"] = 2] = "ExportEquals"; + ExportKind[ExportKind["UMD"] = 3] = "UMD"; + })(ExportKind = ts.ExportKind || (ts.ExportKind = {})); + function createExportMapCache() { + var cache; + var projectVersion; + var usableByFileName; + var wrapped = { + isEmpty: function () { + return !cache; + }, + clear: function () { + cache = undefined; + projectVersion = undefined; + }, + set: function (suggestions, version) { + cache = suggestions; + if (version) { + projectVersion = version; + } + }, + get: function (file, checker, version) { + if (usableByFileName && file !== usableByFileName) { + return undefined; + } + if (version && projectVersion === version) { + return cache; + } + cache === null || cache === void 0 ? void 0 : cache.forEach(function (infos) { + var _a, _b, _c; + for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { + var info = infos_1[_i]; + // If the symbol/moduleSymbol was a merged symbol, it will have a new identity + // in the checker, even though the symbols to merge are the same (guaranteed by + // cache invalidation in synchronizeHostData). + if ((_a = info.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { + info.symbol = checker.getMergedSymbol(info.exportKind === 1 /* Default */ + ? (_b = info.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : info.symbol.declarations[0].symbol + : info.symbol.declarations[0].symbol); + } + if ((_c = info.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { + info.moduleSymbol = checker.getMergedSymbol(info.moduleSymbol.declarations[0].symbol); + } + } + }); + return cache; + }, + onFileChanged: function (oldSourceFile, newSourceFile, typeAcquisitionEnabled) { + if (fileIsGlobalOnly(oldSourceFile) && fileIsGlobalOnly(newSourceFile)) { + // File is purely global; doesn't affect export map + return false; + } + if (usableByFileName && usableByFileName !== newSourceFile.path || + // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. + // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. + typeAcquisitionEnabled && consumesNodeCoreModules(oldSourceFile) !== consumesNodeCoreModules(newSourceFile) || + // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. + // Changes elsewhere in the file can change the *type* of an export in a module augmentation, + // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. + !ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || + !ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { + this.clear(); + return true; + } + usableByFileName = newSourceFile.path; + return false; + }, + }; + if (ts.Debug.isDebugging) { + Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + } + return wrapped; + function fileIsGlobalOnly(file) { + return !file.commonJsModuleIndicator && !file.externalModuleIndicator && !file.moduleAugmentations && !file.ambientModuleNames; + } + function ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile) { + if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { + return false; + } + var oldFileStatementIndex = -1; + var newFileStatementIndex = -1; + var _loop_1 = 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); + if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { + return { value: false }; + } + }; + 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; + } + return true; + } + } + ts.createExportMapCache = createExportMapCache; + function createModuleSpecifierCache() { + var cache; + var importingFileName; + var wrapped = { + get: function (fromFileName, toFileName) { + if (!cache || fromFileName !== importingFileName) + return undefined; + return cache.get(toFileName); + }, + set: function (fromFileName, toFileName, moduleSpecifiers) { + if (cache && fromFileName !== importingFileName) { + cache.clear(); + } + importingFileName = fromFileName; + (cache || (cache = new ts.Map())).set(toFileName, moduleSpecifiers); + }, + clear: function () { + cache = undefined; + importingFileName = undefined; + }, + count: function () { + return cache ? cache.size : 0; + } + }; + if (ts.Debug.isDebugging) { + Object.defineProperty(wrapped, "__cache", { get: function () { return cache; } }); + } + return wrapped; + } + ts.createModuleSpecifierCache = createModuleSpecifierCache; + function isImportableFile(program, from, to, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) { + var _a; + if (from === to) + return false; + var cachedResult = moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.get(from.path, to.path); + if (cachedResult !== undefined) { + return !!cachedResult; + } + var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); + var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); + var hasImportablePath = !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, + /*preferSymlinks*/ false, function (toPath) { + var toFile = program.getSourceFile(toPath); + // Determine to import using toPath only if toPath is what we were looking at + // or there doesnt exist the file in the program by the symlink + return (toFile === to || !toFile) && + isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); + }); + if (packageJsonFilter) { + var isImportable = hasImportablePath && packageJsonFilter.allowsImportingSourceFile(to, moduleSpecifierResolutionHost); + moduleSpecifierCache === null || moduleSpecifierCache === void 0 ? void 0 : moduleSpecifierCache.set(from.path, to.path, isImportable); + return isImportable; + } + return hasImportablePath; + } + ts.isImportableFile = isImportableFile; + /** + * Don't include something from a `node_modules` that isn't actually reachable by a global import. + * A relative import to node_modules is usually a bad idea. + */ + function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { + // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. + var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); + var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); + return toNodeModulesParent === undefined + || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) + || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); + } // #endregion })(ts || (ts = {})); var ts; @@ -118621,13 +122154,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 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 257 /* ModuleDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 252 /* FunctionDeclaration */: + case 222 /* ClassExpression */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -118834,10 +122367,11 @@ var ts; pushClassification(start, width, 1 /* comment */); } function classifyJSDocComment(docComment) { + var _a, _b, _c, _d, _e, _f, _g; var pos = docComment.pos; if (docComment.tags) { - for (var _i = 0, _a = docComment.tags; _i < _a.length; _i++) { - var tag = _a[_i]; + for (var _i = 0, _h = docComment.tags; _i < _h.length; _i++) { + var tag = _h[_i]; // As we walk through each tag, classify the portion of text from the end of // the last tag (or the start of the entire doc comment) as 'comment'. if (tag.pos !== pos) { @@ -118846,22 +122380,56 @@ var ts; pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; + var commentStart = tag.tagName.end; switch (tag.kind) { - case 326 /* JSDocParameterTag */: - processJSDocParameterTag(tag); + case 330 /* JSDocParameterTag */: + var param = tag; + processJSDocParameterTag(param); + commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end; + break; + case 337 /* JSDocPropertyTag */: + var prop = tag; + commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 330 /* JSDocTemplateTag */: + case 334 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; + commentStart = tag.typeParameters.end; + break; + case 335 /* JSDocTypedefTag */: + var type = tag; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 302 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; + break; + case 328 /* JSDocCallbackTag */: + commentStart = tag.typeExpression.end; break; - case 329 /* JSDocTypeTag */: + case 333 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; + commentStart = tag.typeExpression.end; break; - case 327 /* JSDocReturnTag */: + case 332 /* JSDocThisTag */: + case 329 /* JSDocEnumTag */: + commentStart = tag.typeExpression.end; + break; + case 331 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; + commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; + break; + case 336 /* JSDocSeeTag */: + commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; + case 318 /* JSDocAugmentsTag */: + case 319 /* JSDocImplementsTag */: + commentStart = tag.class.end; + break; + } + if (typeof tag.comment === "object") { + pushCommentRange(tag.comment.pos, tag.comment.end - tag.comment.pos); + } + else if (typeof tag.comment === "string") { + pushCommentRange(commentStart, tag.end - commentStart); } } } @@ -119009,22 +122577,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 275 /* JsxOpeningElement */: + case 276 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 276 /* JsxClosingElement */: + case 277 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 274 /* JsxSelfClosingElement */: + case 275 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 280 /* JsxAttribute */: + case 281 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -119053,17 +122621,17 @@ var ts; var parent = token.parent; if (tokenKind === 62 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 249 /* VariableDeclaration */ || - parent.kind === 163 /* PropertyDeclaration */ || - parent.kind === 160 /* Parameter */ || - parent.kind === 280 /* JsxAttribute */) { + if (parent.kind === 250 /* VariableDeclaration */ || + parent.kind === 164 /* PropertyDeclaration */ || + parent.kind === 161 /* Parameter */ || + parent.kind === 281 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 216 /* BinaryExpression */ || - parent.kind === 214 /* PrefixUnaryExpression */ || - parent.kind === 215 /* PostfixUnaryExpression */ || - parent.kind === 217 /* ConditionalExpression */) { + if (parent.kind === 217 /* BinaryExpression */ || + parent.kind === 215 /* PrefixUnaryExpression */ || + parent.kind === 216 /* PostfixUnaryExpression */ || + parent.kind === 218 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -119076,7 +122644,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 280 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 281 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -119092,32 +122660,32 @@ var ts; else if (tokenKind === 78 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 159 /* TypeParameter */: + case 160 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 253 /* InterfaceDeclaration */: + case 254 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 160 /* Parameter */: + case 161 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -119219,13 +122787,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 256 /* ModuleDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 257 /* ModuleDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 252 /* FunctionDeclaration */: + case 222 /* ClassExpression */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -119371,25 +122939,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([ - [249 /* VariableDeclaration */, 7 /* variable */], - [160 /* Parameter */, 6 /* parameter */], - [163 /* PropertyDeclaration */, 9 /* property */], - [256 /* ModuleDeclaration */, 3 /* namespace */], - [255 /* EnumDeclaration */, 1 /* enum */], - [291 /* EnumMember */, 8 /* enumMember */], - [252 /* ClassDeclaration */, 0 /* class */], - [165 /* MethodDeclaration */, 11 /* member */], - [251 /* FunctionDeclaration */, 10 /* function */], - [208 /* FunctionExpression */, 10 /* function */], - [164 /* MethodSignature */, 11 /* member */], - [167 /* GetAccessor */, 9 /* property */], - [168 /* SetAccessor */, 9 /* property */], - [162 /* PropertySignature */, 9 /* property */], - [253 /* InterfaceDeclaration */, 2 /* interface */], - [254 /* TypeAliasDeclaration */, 5 /* type */], - [159 /* TypeParameter */, 4 /* typeParameter */], - [288 /* PropertyAssignment */, 9 /* property */], - [289 /* ShorthandPropertyAssignment */, 9 /* property */] + [250 /* VariableDeclaration */, 7 /* variable */], + [161 /* Parameter */, 6 /* parameter */], + [164 /* PropertyDeclaration */, 9 /* property */], + [257 /* ModuleDeclaration */, 3 /* namespace */], + [256 /* EnumDeclaration */, 1 /* enum */], + [292 /* EnumMember */, 8 /* enumMember */], + [253 /* ClassDeclaration */, 0 /* class */], + [166 /* MethodDeclaration */, 11 /* member */], + [252 /* FunctionDeclaration */, 10 /* function */], + [209 /* FunctionExpression */, 10 /* function */], + [165 /* MethodSignature */, 11 /* member */], + [168 /* GetAccessor */, 9 /* property */], + [169 /* SetAccessor */, 9 /* property */], + [163 /* PropertySignature */, 9 /* property */], + [254 /* InterfaceDeclaration */, 2 /* interface */], + [255 /* TypeAliasDeclaration */, 5 /* type */], + [160 /* TypeParameter */, 4 /* typeParameter */], + [289 /* PropertyAssignment */, 9 /* property */], + [290 /* ShorthandPropertyAssignment */, 9 /* property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -119409,12 +122977,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); - return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, preferences); + var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); + return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, options, preferences); } } StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; - function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, preferences) { + function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, options, preferences) { if (completion === undefined) { return undefined; } @@ -119424,7 +122992,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); // Target will not be used, so arbitrary + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 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 */: { @@ -119441,10 +123009,10 @@ var ts; return ts.Debug.assertNever(completion); } } - function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken) { + function getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, checker, options, host, cancellationToken, preferences) { if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; - var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); + var completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken); } StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; @@ -119493,13 +123061,13 @@ var ts; StringLiteralCompletionKind[StringLiteralCompletionKind["Properties"] = 1] = "Properties"; StringLiteralCompletionKind[StringLiteralCompletionKind["Types"] = 2] = "Types"; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); - function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { + function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 191 /* LiteralType */: { + case 192 /* LiteralType */: { var grandParent = walkUpParentheses(parent.parent); switch (grandParent.kind) { - case 173 /* TypeReference */: { + case 174 /* TypeReference */: { var typeReference_1 = grandParent; var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); if (typeArgument) { @@ -119507,7 +123075,7 @@ var ts; } return undefined; } - case 189 /* IndexedAccessType */: + case 190 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -119519,9 +123087,9 @@ var ts; return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 195 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 182 /* UnionType */: { + case 196 /* ImportType */: + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 183 /* UnionType */: { if (!ts.isTypeReferenceNode(grandParent.parent)) { return undefined; } @@ -119533,7 +123101,7 @@ var ts; return undefined; } } - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -119550,7 +123118,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 202 /* ElementAccessExpression */: { + case 203 /* ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -119563,8 +123131,8 @@ var ts; } return undefined; } - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -119573,16 +123141,16 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 272 /* ExternalModuleReference */: + case 262 /* ImportDeclaration */: + case 268 /* ExportDeclaration */: + case 273 /* 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*/"); // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; + return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } @@ -119594,9 +123162,9 @@ var ts; } function walkUpParentheses(node) { switch (node.kind) { - case 186 /* ParenthesizedType */: + case 187 /* ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -119624,7 +123192,7 @@ var ts; function stringLiteralCompletionsFromProperties(type) { return type && { kind: 1 /* Properties */, - symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)); }), + symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; } @@ -119662,23 +123230,23 @@ var ts; return Math.max(name.indexOf(ts.directorySeparator), name.indexOf(ts.altDirectorySeparator)) !== -1 ? { name: name, kind: kind, extension: extension, span: wholeSpan } : { name: name, kind: kind, extension: extension, span: span }; }); } - function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker)); + function getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) { + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences)); } - function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker) { + function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) { var literalValue = ts.normalizeSlashes(node.text); 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) + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); } function getExtensionOptions(compilerOptions, includeExtensions) { if (includeExtensions === void 0) { includeExtensions = false; } return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensions: includeExtensions }; } - function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath) { - var extensionOptions = getExtensionOptions(compilerOptions); + function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, preferences) { + var extensionOptions = getExtensionOptions(compilerOptions, preferences.importModuleSpecifierEnding === "js"); if (compilerOptions.rootDirs) { return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } @@ -119795,7 +123363,7 @@ var ts; continue; var patterns = paths[path]; if (patterns) { - var _loop_1 = function (name, kind, extension) { + var _loop_2 = 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)); @@ -119803,7 +123371,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_1(name, kind, extension); + _loop_2(name, kind, extension); } } } @@ -119838,7 +123406,7 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_2 = function (moduleName) { + var _loop_3 = function (moduleName) { if (!result.some(function (entry) { return entry.name === moduleName; })) { foundGlobal = true; result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); @@ -119846,7 +123414,7 @@ var ts; }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { var moduleName = _c[_b]; - _loop_2(moduleName); + _loop_3(moduleName); } } if (!foundGlobal) { @@ -120093,6 +123661,7 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["Export"] = 4] = "Export"; SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise"; SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable"; + SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport"; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); @@ -120105,8 +123674,14 @@ var ts; function originIsExport(origin) { return !!(origin && origin.kind & 4 /* Export */); } + function originIsResolvedExport(origin) { + return !!(origin && origin.kind === 32 /* ResolvedExport */); + } + function originIncludesSymbolName(origin) { + return originIsExport(origin) || originIsResolvedExport(origin); + } function originIsPackageJsonImport(origin) { - return originIsExport(origin) && !!origin.isFromPackageJson; + return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { return !!(origin.kind & 8 /* Promise */); @@ -120132,52 +123707,6 @@ var ts; GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success"; GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail"; })(GlobalsSearch || (GlobalsSearch = {})); - function createImportSuggestionsForFileCache() { - var cache; - var projectVersion; - var fileName; - return { - isEmpty: function () { - return !cache; - }, - clear: function () { - cache = undefined; - fileName = undefined; - projectVersion = undefined; - }, - set: function (file, suggestions, version) { - cache = suggestions; - fileName = file; - if (version) { - projectVersion = version; - } - }, - get: function (file, checker, version) { - if (file !== fileName) { - return undefined; - } - if (version) { - return projectVersion === version ? cache : undefined; - } - ts.forEach(cache, function (suggestion) { - var _a, _b, _c; - // If the symbol/moduleSymbol was a merged symbol, it will have a new identity - // in the checker, even though the symbols to merge are the same (guaranteed by - // cache invalidation in synchronizeHostData). - if ((_a = suggestion.symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) { - suggestion.symbol = checker.getMergedSymbol(suggestion.origin.isDefaultExport - ? (_b = suggestion.symbol.declarations[0].localSymbol) !== null && _b !== void 0 ? _b : suggestion.symbol.declarations[0].symbol - : suggestion.symbol.declarations[0].symbol); - } - if ((_c = suggestion.origin.moduleSymbol.declarations) === null || _c === void 0 ? void 0 : _c.length) { - suggestion.origin.moduleSymbol = checker.getMergedSymbol(suggestion.origin.moduleSymbol.declarations[0].symbol); - } - }); - return cache; - }, - }; - } - Completions.createImportSuggestionsForFileCache = createImportSuggestionsForFileCache; function getCompletionsAtPosition(host, program, log, sourceFile, position, preferences, triggerCharacter) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); @@ -120185,6 +123714,13 @@ var ts; if (triggerCharacter && !ts.isInString(sourceFile, position, contextToken) && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) { return undefined; } + if (triggerCharacter === " ") { + // `isValidTrigger` ensures we are at `import |` + if (preferences.includeCompletionsForImportStatements && preferences.includeCompletionsWithInsertText) { + return { isGlobalCompletion: true, isMemberCompletion: false, isNewIdentifierLocation: true, isIncomplete: true, entries: [] }; + } + return undefined; + } var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, contextToken, typeChecker, compilerOptions, host, log, preferences); if (stringCompletions) { return stringCompletions; @@ -120208,6 +123744,8 @@ var ts; return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); case 3 /* JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); + case 4 /* Keywords */: + return specificKeywordCompletionInfo(completionData.keywords); default: return ts.Debug.assertNever(completionData); } @@ -120216,33 +123754,36 @@ var ts; function jsdocCompletionInfo(entries) { return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: entries }; } + function specificKeywordCompletionInfo(keywords) { + 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, + }); }), + }; + } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts return (location === null || location === void 0 ? void 0 : location.kind) === 78 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } 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, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap; - if (location && location.parent && ts.isJsxClosingElement(location.parent)) { - // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, - // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. - // For example: - // var x =
" with type any - // And at `
` (with a closing `>`), the completion list will contain "div". - var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); - var entry = { - name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), - kind: "class" /* classElement */, - kindModifiers: undefined, - sortText: SortText.LocationPriority, - }; - return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: getOptionalReplacementSpan(location), entries: [entry] }; + var symbols = completionData.symbols, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap; + // Verify if the file is JSX language variant + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + var completionInfo = getJsxClosingTagCompletion(location, sourceFile); + if (completionInfo) { + return completionInfo; + } } var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 } else { @@ -120250,7 +123791,7 @@ var ts; return undefined; } getCompletionEntriesFromSymbols(symbols, entries, - /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); } if (keywordFilters !== 0 /* None */) { var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); @@ -120286,6 +123827,49 @@ var ts; return false; } } + function getJsxClosingTagCompletion(location, sourceFile) { + // We wanna walk up the tree till we find a JSX closing element + var jsxClosingElement = ts.findAncestor(location, function (node) { + switch (node.kind) { + case 277 /* JsxClosingElement */: + return true; + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: + case 78 /* Identifier */: + case 202 /* PropertyAccessExpression */: + return false; + default: + return "quit"; + } + }); + if (jsxClosingElement) { + // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, + // instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element. + // For example: + // var x =
" with type any + // And at `
` (with a closing `>`), the completion list will contain "div". + // And at property access expressions ` ` the completion will + // return full closing tag with an optional replacement span + // For example: + // var x = + // var y = + // the completion list at "1" and "2" will contain "MainComponent.Child" with a replacement span of closing tag name + var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* GreaterThanToken */, sourceFile); + var tagName = jsxClosingElement.parent.openingElement.tagName; + var closingTag = tagName.getText(sourceFile); + var fullClosingTag = closingTag + (hasClosingAngleBracket ? "" : ">"); + var replacementSpan = ts.createTextSpanFromNode(jsxClosingElement.tagName); + var entry = { + name: fullClosingTag, + kind: "class" /* classElement */, + kindModifiers: undefined, + sortText: SortText.LocationPriority, + }; + return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, optionalReplacementSpan: replacementSpan, entries: [entry] }; + } + return; + } function getJSCompletionEntries(sourceFile, position, uniqueNames, target, entries) { ts.getNameTable(sourceFile).forEach(function (pos, name) { // Skip identifiers produced only from the current location @@ -120312,9 +123896,13 @@ 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, preferences) { + function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences) { + var _a; var insertText; var replacementSpan = ts.getReplacementSpanForContextToken(contextToken); + var data; + var isSnippet; + var sourceDisplay; var insertQuestionDot = origin && originIsNullableMember(origin); var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { @@ -120358,9 +123946,24 @@ var ts; insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } + if (originIsResolvedExport(origin)) { + ts.Debug.assertIsDefined(importCompletionNode); + (_a = getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences), insertText = _a.insertText, replacementSpan = _a.replacementSpan); + sourceDisplay = [ts.textPart(origin.moduleSpecifier)]; + isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } + if (originIsExport(origin) || originIsResolvedExport(origin)) { + data = { + exportName: origin.exportName, + fileName: origin.fileName, + ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name), + isPackageJsonImport: origin.isFromPackageJson ? true : undefined, + moduleSpecifier: originIsResolvedExport(origin) ? origin.moduleSpecifier : undefined, + }; + } // TODO(drosen): Right now we just permit *all* semantic meanings when calling // 'getSymbolKind' which is permissible given that it is backwards compatible; but // really we should consider passing the meaning for the node so that we don't report @@ -120378,9 +123981,30 @@ var ts; isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined, insertText: insertText, replacementSpan: replacementSpan, + sourceDisplay: sourceDisplay, + isSnippet: isSnippet, isPackageJsonImport: originIsPackageJsonImport(origin) || undefined, + isImportStatementCompletion: originIsResolvedExport(origin) || undefined, + data: data, }; } + function getInsertTextAndReplacementSpanForImportCompletion(name, importCompletionNode, origin, useSemicolons, options, preferences) { + var sourceFile = importCompletionNode.getSourceFile(); + var replacementSpan = ts.createTextSpanFromNode(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); + var suffix = useSemicolons ? ";" : ""; + switch (importKind) { + case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; + case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import * as " + name + tabStop + " from " + quotedModuleSpecifier + suffix }; + case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import { " + name + tabStop + " } from " + quotedModuleSpecifier + suffix }; + } + } function quotePropertyName(sourceFile, preferences, name) { if (/^\d+$/.test(name)) { return name; @@ -120395,29 +124019,31 @@ var ts; if (originIsExport(origin)) { return ts.stripQuotes(origin.moduleSymbol.name); } + if (originIsResolvedExport(origin)) { + return origin.moduleSpecifier; + } if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { return CompletionSource.ThisProperty; } } - function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) { + function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) { var start = ts.timestamp(); + var variableDeclaration = getVariableDeclaration(location); + var useSemicolons = ts.probablyUsesSemicolons(sourceFile); // 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. // So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name. var uniques = new ts.Map(); - for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { - var symbol = symbols_1[_i]; - var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined; + for (var i = 0; i < symbols.length; i++) { + var symbol = symbols[i]; + var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); - if (!info) { + if (!info || uniques.get(info.name) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; - if (uniques.get(name)) { - continue; - } - var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences); + var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences); if (!entry) { continue; } @@ -120434,6 +124060,46 @@ var ts; has: function (name) { return uniques.has(name); }, add: function (name) { return uniques.set(name, true); }, }; + function shouldIncludeSymbol(symbol, symbolToSortTextMap) { + if (!ts.isSourceFile(location)) { + // export = /**/ here we want to get all meanings, so any symbol is ok + if (ts.isExportAssignment(location.parent)) { + return true; + } + // Filter out variables from their own initializers + // `const a = /* no 'a' here */` + if (variableDeclaration && symbol.valueDeclaration === variableDeclaration) { + return false; + } + // External modules can have global export declarations that will be + // available as global keywords in all scopes. But if the external module + // already has an explicit export and user only wants to user explicit + // module imports then the global keywords will be filtered out so auto + // import suggestions will win in the completion + var symbolOrigin = ts.skipAlias(symbol, typeChecker); + // We only want to filter out the global keywords + // Auto Imports are not available for scripts so this conditional is always false + if (!!sourceFile.externalModuleIndicator + && !compilerOptions.allowUmdGlobalAccess + && symbolToSortTextMap[ts.getSymbolId(symbol)] === SortText.GlobalsOrKeywords + && (symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === SortText.AutoImportSuggestions + || symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === SortText.LocationPriority)) { + return false; + } + // Continue with origin symbol + symbol = symbolOrigin; + // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) + if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { + return !!(symbol.flags & 1920 /* Namespace */); + } + if (isTypeOnlyLocation) { + // It's a type, but you can reach it by namespace.type as well + return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); + } + } + // expressions are value space (which includes the value namespaces) + return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); + } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; function getLabelCompletionAtPosition(node) { @@ -120467,6 +124133,20 @@ var ts; return entries; } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) { + if (entryId.data) { + var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host); + if (autoImport) { + return { + type: "symbol", + symbol: autoImport.symbol, + location: ts.getTouchingPropertyName(sourceFile, position), + previousToken: ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined), + isJsxInitializer: false, + isTypeOnlyLocation: false, + origin: autoImport.origin, + }; + } + } var compilerOptions = program.getCompilerOptions(); var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { @@ -120483,11 +124163,11 @@ var ts; // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - return ts.firstDefined(symbols, function (symbol) { - var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; + 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, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } + ? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; }) || { type: "none" }; } @@ -120497,7 +124177,7 @@ var ts; var name = entryId.name; var contextToken = ts.findPrecedingToken(position, sourceFile); if (ts.isInString(sourceFile, position, contextToken)) { - return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); + return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences); } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences); @@ -120511,13 +124191,15 @@ var ts; return ts.JsDoc.getJSDocTagCompletionDetails(name); 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; default: return ts.Debug.assertNever(request); } } case "symbol": { - var symbol = symbolCompletion.symbol, location = symbolCompletion.location, symbolToOriginInfoMap = symbolCompletion.symbolToOriginInfoMap, previousToken = symbolCompletion.previousToken; - var _a = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; + var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken; + var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, typeChecker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "literal": { @@ -120543,15 +124225,17 @@ var ts; } Completions.createCompletionDetailsForSymbol = createCompletionDetailsForSymbol; function createCompletionDetails(name, kindModifiers, kind, displayParts, documentation, tags, codeActions, source) { - return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source }; + return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source }; } Completions.createCompletionDetails = createCompletionDetails; - function getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences) { - var symbolOriginInfo = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; - if (!symbolOriginInfo || !originIsExport(symbolOriginInfo)) { + function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, checker, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) { + if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) { + return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] }; + } + if (!origin || !originIsExport(origin)) { return { codeActions: undefined, sourceDisplay: undefined }; } - var moduleSymbol = symbolOriginInfo.moduleSymbol; + var moduleSymbol = origin.moduleSymbol; var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -120567,6 +124251,7 @@ var ts; CompletionDataKind[CompletionDataKind["JsDocTagName"] = 1] = "JsDocTagName"; CompletionDataKind[CompletionDataKind["JsDocTag"] = 2] = "JsDocTag"; CompletionDataKind[CompletionDataKind["JsDocParameterName"] = 3] = "JsDocParameterName"; + CompletionDataKind[CompletionDataKind["Keywords"] = 4] = "Keywords"; })(CompletionDataKind || (CompletionDataKind = {})); var CompletionKind; (function (CompletionKind) { @@ -120594,11 +124279,11 @@ var ts; return ts.getContextualTypeFromParent(previousToken, checker); case 62 /* EqualsToken */: switch (parent.kind) { - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 280 /* JsxAttribute */: + case 281 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -120608,7 +124293,7 @@ var ts; case 81 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 273 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 274 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? @@ -120627,11 +124312,11 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 297 /* SourceFile */; }); + var _a; + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 298 /* SourceFile */; })); } function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); - var compilerOptions = program.getCompilerOptions(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) @@ -120679,11 +124364,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 301 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 333 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 337 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -120708,7 +124393,7 @@ var ts; var contextToken = previousToken; // Check if the caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier and adjust the contextToken to the token that precedes it. - if (contextToken && position <= contextToken.end && (ts.isIdentifierOrPrivateIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { + if (contextToken && position <= contextToken.end && (ts.isMemberName(contextToken) || ts.isKeyword(contextToken.kind))) { var start_1 = ts.timestamp(); contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_1)); @@ -120724,10 +124409,22 @@ var ts; var isStartingCloseTag = false; var isJsxInitializer = false; var isJsxIdentifierExpected = false; + var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { + var importCompletionCandidate = getImportCompletionNode(contextToken); + if (importCompletionCandidate === 153 /* FromKeyword */) { + return { kind: 4 /* Keywords */, keywords: [153 /* FromKeyword */] }; + } + // Import statement completions use `insertText`, and also require the `data` property of `CompletionEntryIdentifier` + // added in TypeScript 4.3 to be sent back from the client during `getCompletionEntryDetails`. Since this feature + // 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; + } // Bail out if this is a known invalid completion location - if (isCompletionListBlocker(contextToken)) { + if (!importCompletionNode && isCompletionListBlocker(contextToken)) { log("Returning an empty list because completion was requested in an invalid position."); return undefined; } @@ -120736,7 +124433,7 @@ var ts; isRightOfDot = contextToken.kind === 24 /* DotToken */; isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && @@ -120749,14 +124446,14 @@ var ts; return undefined; } break; - case 157 /* QualifiedName */: + case 158 /* QualifiedName */: node = parent.left; break; - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: node = parent.name; break; - case 195 /* ImportType */: - case 226 /* MetaProperty */: + case 196 /* ImportType */: + case 227 /* MetaProperty */: node = parent; break; default: @@ -120765,11 +124462,11 @@ var ts; return undefined; } } - else if (sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* JSX */) { // // 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 === 201 /* PropertyAccessExpression */) { + if (parent && parent.kind === 202 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -120777,45 +124474,45 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 273 /* JsxElement */ || currentToken.parent.kind === 275 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 274 /* JsxElement */ || currentToken.parent.kind === 276 /* JsxOpeningElement */) { location = currentToken; } break; case 43 /* SlashToken */: - if (currentToken.parent.kind === 274 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 275 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 276 /* JsxClosingElement */: + case 277 /* JsxClosingElement */: if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 274 /* JsxSelfClosingElement */: - case 273 /* JsxElement */: - case 275 /* JsxOpeningElement */: + case 275 /* JsxSelfClosingElement */: + case 274 /* JsxElement */: + case 276 /* JsxOpeningElement */: isJsxIdentifierExpected = true; if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 283 /* JsxExpression */: + case 284 /* JsxExpression */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 280 /* JsxAttribute */: + case 281 /* JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -120849,8 +124546,11 @@ var ts; var symbols = []; var symbolToOriginInfoMap = []; var symbolToSortTextMap = []; - var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + var seenPropertySymbols = new ts.Map(); var isTypeOnly = isTypeOnlyCompletion(); + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } @@ -120859,7 +124559,7 @@ var ts; ts.Debug.assertEachIsDefined(tagSymbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); symbols = tagSymbols.concat(symbols); - completionKind = 3 /* MemberLike */; + completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } else if (isStartingCloseTag) { @@ -120868,7 +124568,7 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 3 /* MemberLike */; + completionKind = 1 /* Global */; keywordFilters = 0 /* None */; } else { @@ -120901,14 +124601,15 @@ var ts; symbolToSortTextMap: symbolToSortTextMap, isTypeOnlyLocation: isTypeOnly, isJsxIdentifierExpected: isJsxIdentifierExpected, + importCompletionNode: importCompletionNode, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: - case 327 /* JSDocReturnTag */: - case 329 /* JSDocTypeTag */: - case 331 /* JSDocTypedefTag */: + case 330 /* JSDocParameterTag */: + case 337 /* JSDocPropertyTag */: + case 331 /* JSDocReturnTag */: + case 333 /* JSDocTypeTag */: + case 335 /* JSDocTypedefTag */: return true; default: return false; @@ -120936,10 +124637,10 @@ var ts; var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : (node.parent), symbol.name); }; - var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol); }; + var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); }; var isValidAccess = isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. - ? function (symbol) { return !!(symbol.flags & 1920 /* Namespace */) && !symbol.declarations.every(function (d) { return d.parent === node.parent; }); } + ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -120953,7 +124654,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 !== 297 /* SourceFile */ && d.kind !== 256 /* ModuleDeclaration */ && d.kind !== 255 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 298 /* SourceFile */ && d.kind !== 257 /* ModuleDeclaration */ && d.kind !== 256 /* EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -121000,7 +124701,7 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 195 /* ImportType */ ? node : node.parent; + var propertyAccess = node.kind === 196 /* 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 @@ -121039,13 +124740,24 @@ var ts; var nameSymbol = leftMostName && typeChecker.getSymbolAtLocation(leftMostName); // If this is nested like for `namespace N { export const sym = Symbol(); }`, we'll add the completion for `N`. var firstAccessibleSymbol = nameSymbol && getFirstSymbolInChain(nameSymbol, contextToken, typeChecker); - if (firstAccessibleSymbol && !symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)]) { + if (firstAccessibleSymbol && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(firstAccessibleSymbol))) { + var index = symbols.length; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; - symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) - ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } - : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; + if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol)) { + 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; + } } else if (preferences.includeCompletionsWithInsertText) { addSymbolOriginInfo(symbol); @@ -121065,11 +124777,11 @@ var ts; } function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { - if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; } } } @@ -121082,7 +124794,9 @@ var ts; return ts.isIdentifier(e) ? e : ts.isPropertyAccessExpression(e) ? getLeftMostName(e.expression) : undefined; } function tryGetGlobalSymbols() { - var result = tryGetObjectLikeCompletionSymbols() + var result = tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() + || tryGetObjectLikeCompletionSymbols() + || tryGetImportCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() @@ -121115,6 +124829,12 @@ var ts; isNewIdentifierLocation = false; return 1 /* Success */; } + function tryGetImportCompletionSymbols() { + if (!importCompletionNode) + return 0 /* Continue */; + collectAutoImports(/*resolveModuleSpecifiers*/ true); + return 1 /* Success */; + } function getGlobalCompletions() { keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; // Get all entities in the current scope. @@ -121156,50 +124876,36 @@ var ts; var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); - for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { - var symbol = symbols_2[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; if (!typeChecker.isArgumentsSymbol(symbol) && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.GlobalsOrKeywords; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 297 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 298 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; } } } - if (shouldOfferImportCompletions()) { - var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; - var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); - if (!detailsEntryId && importSuggestionsCache) { - importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); - } - autoImportSuggestions.forEach(function (_a) { - var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; - if (detailsEntryId) { - if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { - return; - } - } - else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { - return; - } - var symbolId = ts.getSymbolId(symbol); - symbols.push(symbol); - symbolToOriginInfoMap[symbolId] = origin; - symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; - }); + collectAutoImports(/*resolveModuleSpecifier*/ false); + if (isTypeOnly) { + keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) + ? 6 /* TypeAssertionKeywords */ + : 7 /* TypeKeywords */; } - filterGlobalCompletion(symbols); } function shouldOfferImportCompletions() { + // If already typing an import statement, provide completions for it. + if (importCompletionNode) + return true; // If current completion is for non-contextual Object literal shortahands, ignore auto-import symbols if (isNonContextualObjectLiteral) return false; @@ -121217,75 +124923,15 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 297 /* SourceFile */: - case 218 /* TemplateExpression */: - case 283 /* JsxExpression */: - case 230 /* Block */: + case 298 /* SourceFile */: + case 219 /* TemplateExpression */: + case 284 /* JsxExpression */: + case 231 /* Block */: return true; default: return ts.isStatement(scopeNode); } } - function filterGlobalCompletion(symbols) { - var isTypeOnly = isTypeOnlyCompletion(); - if (isTypeOnly) { - keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; - } - var variableDeclaration = getVariableDeclaration(location); - ts.filterMutate(symbols, function (symbol) { - if (!ts.isSourceFile(location)) { - // export = /**/ here we want to get all meanings, so any symbol is ok - if (ts.isExportAssignment(location.parent)) { - return true; - } - // Filter out variables from their own initializers - // `const a = /* no 'a' here */` - if (variableDeclaration && symbol.valueDeclaration === variableDeclaration) { - return false; - } - // External modules can have global export declarations that will be - // available as global keywords in all scopes. But if the external module - // already has an explicit export and user only wants to user explicit - // module imports then the global keywords will be filtered out so auto - // import suggestions will win in the completion - var symbolOrigin = ts.skipAlias(symbol, typeChecker); - // We only want to filter out the global keywords - // Auto Imports are not available for scripts so this conditional is always false - if (!!sourceFile.externalModuleIndicator - && !compilerOptions.allowUmdGlobalAccess - && symbolToSortTextMap[ts.getSymbolId(symbol)] === SortText.GlobalsOrKeywords - && symbolToSortTextMap[ts.getSymbolId(symbolOrigin)] === SortText.AutoImportSuggestions) { - return false; - } - // Continue with origin symbol - symbol = symbolOrigin; - // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) - if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(symbol.flags & 1920 /* Namespace */); - } - if (isTypeOnly) { - // It's a type, but you can reach it by namespace.type as well - return symbolCanBeReferencedAtTypeLocation(symbol); - } - } - // expressions are value space (which includes the value namespaces) - return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */); - }); - } - function getVariableDeclaration(property) { - var variableDeclaration = ts.findAncestor(property, function (node) { - return ts.isFunctionBlock(node) || isArrowFunctionBody(node) || ts.isBindingPattern(node) - ? "quit" - : ts.isVariableDeclaration(node); - }); - return variableDeclaration; - } - function isArrowFunctionBody(node) { - return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node; - } - ; function isTypeOnlyCompletion() { return insideJsDocTagTypeExpression || !isContextTokenValueLocation(contextToken) && @@ -121295,191 +124941,105 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 111 /* TypeOfKeyword */ && - (contextToken.parent.kind === 176 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + ((contextToken.kind === 111 /* TypeOfKeyword */ && + (contextToken.parent.kind === 177 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 127 /* AssertsKeyword */ && contextToken.parent.kind === 173 /* TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 58 /* ColonToken */: - return parentKind === 163 /* PropertyDeclaration */ || - parentKind === 162 /* PropertySignature */ || - parentKind === 160 /* Parameter */ || - parentKind === 249 /* VariableDeclaration */ || + return parentKind === 164 /* PropertyDeclaration */ || + parentKind === 163 /* PropertySignature */ || + parentKind === 161 /* Parameter */ || + parentKind === 250 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 62 /* EqualsToken */: - return parentKind === 254 /* TypeAliasDeclaration */; + return parentKind === 255 /* TypeAliasDeclaration */; case 126 /* AsKeyword */: - return parentKind === 224 /* AsExpression */; + return parentKind === 225 /* AsExpression */; case 29 /* LessThanToken */: - return parentKind === 173 /* TypeReference */ || - parentKind === 206 /* TypeAssertionExpression */; + return parentKind === 174 /* TypeReference */ || + parentKind === 207 /* TypeAssertionExpression */; case 93 /* ExtendsKeyword */: - return parentKind === 159 /* TypeParameter */; + return parentKind === 160 /* TypeParameter */; } } return false; } - /** True if symbol is a type or a module containing at least one type. */ - function symbolCanBeReferencedAtTypeLocation(symbol, seenModules) { - if (seenModules === void 0) { seenModules = new ts.Map(); } - var sym = ts.skipAlias(symbol.exportSymbol || symbol, typeChecker); - return !!(sym.flags & 788968 /* Type */) || - !!(sym.flags & 1536 /* Module */) && - ts.addToSeen(seenModules, ts.getSymbolId(sym)) && - typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); - } - /** - * Gathers symbols that can be imported from other files, de-duplicating along the way. Symbols can be "duplicates" - * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but - * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, - * if and only if the the first can be imported (it may be excluded due to package.json filtering in - * `codefix.forEachExternalModuleToImportFrom`). - * - * Example. Imagine a chain of node_modules re-exporting one original symbol: - * - * ```js - * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js - * +-----------------------+ +--------------------------+ +--------------------------+ - * | | | | | | - * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | - * | | | | | | - * +-----------------------+ +--------------------------+ +--------------------------+ - * ``` - * - * Also imagine three buckets, which we’ll reference soon: - * - * ```md - * | | | | | | - * | **Bucket A** | | **Bucket B** | | **Bucket C** | - * | Symbols to | | Aliases to symbols | | Symbols to return | - * | definitely | | in Buckets A or C | | if nothing better | - * | return | | (don’t return these) | | comes along | - * |__________________| |______________________| |___________________| - * ``` - * - * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it - * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not - * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we - * may not be sure whether or not it should go in the list. So, we’ll take the following steps: - * - * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is - * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B - * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. - * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. - * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' - * should never be returned in the final list, so put it in Bucket B. - * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so - * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. - * Put this symbol in Bucket A. - * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t - * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move - * everything from Bucket C to Bucket A. - */ - function getSymbolsFromOtherSourceFileExports(target, host) { - var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); - if (cached) { - log("getSymbolsFromOtherSourceFileExports: Using cached list"); - return cached; - } - var startTime = ts.timestamp(); - log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); - var seenResolvedModules = new ts.Map(); - var seenExports = new ts.Map(); - /** Bucket B */ - var aliasesToAlreadyIncludedSymbols = new ts.Map(); - /** Bucket C */ - var aliasesToReturnIfOriginalsAreMissing = new ts.Map(); - /** Bucket A */ - var results = []; - /** Ids present in `results` for faster lookup */ - var resultSymbolIds = new ts.Map(); - ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, /*useAutoImportProvider*/ true, function (moduleSymbol, _, program, isFromPackageJson) { - // Perf -- ignore other modules if this is a request for details - if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { - return; - } - var typeChecker = program.getTypeChecker(); - var resolvedModuleSymbol = typeChecker.resolveExternalModuleSymbol(moduleSymbol); - // resolvedModuleSymbol may be a namespace. A namespace may be `export =` by multiple module declarations, but only keep the first one. - if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { + /** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextMap` */ + function collectAutoImports(resolveModuleSpecifiers) { + var _a, _b, _c, _d, _e; + if (!shouldOfferImportCompletions()) + return; + ts.Debug.assert(!(detailsEntryId === null || detailsEntryId === void 0 ? void 0 : detailsEntryId.data)); + var start = ts.timestamp(); + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "collectAutoImports: starting, " + (resolveModuleSpecifiers ? "" : "not ") + "resolving module specifiers"); + if (moduleSpecifierCache) { + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "collectAutoImports: module specifier cache size: " + moduleSpecifierCache.count()); + } + var lowerCaseTokenText = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var exportInfo = ts.codefix.getSymbolToExportInfoMap(sourceFile, host, program); + var packageJsonAutoImportProvider = (_d = host.getPackageJsonAutoImportProvider) === null || _d === void 0 ? void 0 : _d.call(host); + var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, host); + exportInfo.forEach(function (info, key) { + var symbolName = key.substring(0, key.indexOf("|")); + if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return; - } - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - if (resolvedModuleSymbol !== moduleSymbol && ts.every(resolvedModuleSymbol.declarations, ts.isNonGlobalDeclaration)) { - pushSymbol(resolvedModuleSymbol, moduleSymbol, isFromPackageJson, /*skipFilter*/ true); - } - for (var _i = 0, _a = typeChecker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { - var symbol = _a[_i]; - var symbolId = ts.getSymbolId(symbol).toString(); - // `getExportsAndPropertiesOfModule` can include duplicates - if (!ts.addToSeen(seenExports, symbolId)) { - continue; - } - // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. - if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { - continue; - } - // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. - var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; - // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { - // Walk the export chain back one module (step 1 or 2 in diagrammed example). - // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. - var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); - if (!nearestExportSymbol) - continue; - var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); - var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); - if (!symbolHasBeenSeen) { - aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol, isFromPackageJson: isFromPackageJson }); - aliasesToAlreadyIncludedSymbols.set(symbolId, true); - } - else { - // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here - // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. - ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); - } - } - else { - // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.delete(symbolId); - pushSymbol(symbol, moduleSymbol, isFromPackageJson, /*skipFilter*/ false); - } + var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); }); + if (isCompletionDetailsMatch || isNameMatch(symbolName)) { + // If we don't need to resolve module specifiers, we can use any re-export that is importable at all + // (We need to ensure that at least one is importable to show a completion.) + var _a = resolveModuleSpecifiers + ? ts.codefix.getModuleSpecifierForBestExportInfo(info, sourceFile, program, host, preferences) + : { moduleSpecifier: undefined, exportInfo: ts.find(info, isImportableExportInfo) }, moduleSpecifier = _a.moduleSpecifier, exportInfo_1 = _a.exportInfo; + if (!exportInfo_1) + return; + var moduleFile = ts.tryCast(exportInfo_1.moduleSymbol.valueDeclaration, ts.isSourceFile); + var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */; + var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol; + pushAutoImportSymbol(symbol, { + kind: resolveModuleSpecifiers ? 32 /* ResolvedExport */ : 4 /* Export */, + moduleSpecifier: moduleSpecifier, + symbolName: symbolName, + exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name, + fileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, + isDefaultExport: isDefaultExport, + moduleSymbol: exportInfo_1.moduleSymbol, + isFromPackageJson: exportInfo_1.isFromPackageJson, + }); } }); - // By this point, any potential duplicates that were actually duplicates have been - // removed, so the rest need to be added. (Step 4 in diagrammed example) - aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { - var alias = _a.alias, moduleSymbol = _a.moduleSymbol, isFromPackageJson = _a.isFromPackageJson; - return pushSymbol(alias, moduleSymbol, isFromPackageJson, /*skipFilter*/ false); - }); - log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); - return results; - function pushSymbol(symbol, moduleSymbol, isFromPackageJson, skipFilter) { - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "collectAutoImports: done in " + (ts.timestamp() - start) + " ms"); + function isNameMatch(symbolName) { + var lowerCaseSymbolName = symbolName.toLowerCase(); + if (resolveModuleSpecifiers && lowerCaseTokenText) { + // Use a more restrictive filter if resolving module specifiers since resolving module specifiers is expensive. + return lowerCaseTokenText[0] === lowerCaseSymbolName[0] && stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); } - if (typeChecker.isUndefinedSymbol(symbol)) { - return; + return stringContainsCharactersInOrder(lowerCaseSymbolName, lowerCaseTokenText); + } + function isImportableExportInfo(info) { + var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); + if (!moduleFile) { + return packageJsonFilter + ? packageJsonFilter.allowsImportingAmbientModule(info.moduleSymbol, getModuleSpecifierResolutionHost(info.isFromPackageJson)) + : true; } - ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); - var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport, isFromPackageJson: isFromPackageJson }; - results.push({ - symbol: symbol, - symbolName: ts.getNameForExportedSymbol(symbol, target), - origin: origin, - skipFilter: skipFilter, - }); + return ts.isImportableFile(info.isFromPackageJson ? packageJsonAutoImportProvider : program, sourceFile, moduleFile, packageJsonFilter, getModuleSpecifierResolutionHost(info.isFromPackageJson), moduleSpecifierCache); } } - function getNearestExportSymbol(fromSymbol) { - return findAlias(typeChecker, fromSymbol, function (alias) { - return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); - }); + function pushAutoImportSymbol(symbol, origin) { + var symbolId = ts.getSymbolId(symbol); + if (symbolToSortTextMap[symbolId] === SortText.GlobalsOrKeywords) { + // If an auto-importable symbol is available as a global, don't add the auto import + return; + } + symbolToOriginInfoMap[symbols.length] = origin; + symbolToSortTextMap[symbolId] = importCompletionNode ? SortText.LocationPriority : SortText.AutoImportSuggestions; + symbols.push(symbol); } /** * True if you could remove some characters in `a` to get `b`. @@ -121491,7 +125051,8 @@ var ts; return true; } var characterIndex = 0; - for (var strIndex = 0; strIndex < str.length; strIndex++) { + var len = str.length; + for (var strIndex = 0; strIndex < len; strIndex++) { if (str.charCodeAt(strIndex) === characters.charCodeAt(characterIndex)) { characterIndex++; if (characterIndex === characters.length) { @@ -121527,7 +125088,7 @@ var ts; return true; } if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 275 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 276 /* JsxOpeningElement */) { // Two possibilities: // 1.
/**/ // - contextToken: GreaterThanToken (before cursor) @@ -121537,10 +125098,10 @@ var ts; // - contextToken: GreaterThanToken (before cursor) // - location: GreaterThanToken (after cursor) // - same parent (JSXOpeningElement) - return location.parent.kind !== 275 /* JsxOpeningElement */; + return location.parent.kind !== 276 /* JsxOpeningElement */; } - if (contextToken.parent.kind === 276 /* JsxClosingElement */ || contextToken.parent.kind === 274 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 273 /* JsxElement */; + if (contextToken.parent.kind === 277 /* JsxClosingElement */ || contextToken.parent.kind === 275 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 274 /* JsxElement */; } } return false; @@ -121551,42 +125112,42 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { case 27 /* CommaToken */: - return containingNodeKind === 203 /* CallExpression */ // func( a, | - || containingNodeKind === 166 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 204 /* NewExpression */ // new C(a, | - || containingNodeKind === 199 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 216 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 174 /* FunctionType */ // var x: (s: string, list| - || containingNodeKind === 200 /* ObjectLiteralExpression */; // const obj = { x, | + return containingNodeKind === 204 /* CallExpression */ // func( a, | + || containingNodeKind === 167 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 205 /* NewExpression */ // new C(a, | + || containingNodeKind === 200 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 217 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 175 /* FunctionType */ // var x: (s: string, list| + || containingNodeKind === 201 /* ObjectLiteralExpression */; // const obj = { x, | case 20 /* OpenParenToken */: - return containingNodeKind === 203 /* CallExpression */ // func( | - || containingNodeKind === 166 /* Constructor */ // constructor( | - || containingNodeKind === 204 /* NewExpression */ // new C(a| - || containingNodeKind === 207 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 186 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 204 /* CallExpression */ // func( | + || containingNodeKind === 167 /* Constructor */ // constructor( | + || containingNodeKind === 205 /* NewExpression */ // new C(a| + || containingNodeKind === 208 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 187 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 199 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 171 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 158 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 200 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 172 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 159 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 139 /* ModuleKeyword */: // module | case 140 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 256 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 257 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 252 /* ClassDeclaration */ // class A { | - || containingNodeKind === 200 /* ObjectLiteralExpression */; // const obj = { | + return containingNodeKind === 253 /* ClassDeclaration */ // class A { | + || containingNodeKind === 201 /* ObjectLiteralExpression */; // const obj = { | case 62 /* EqualsToken */: - return containingNodeKind === 249 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 216 /* BinaryExpression */; // x = a| + return containingNodeKind === 250 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 217 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 218 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 219 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 228 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 229 /* TemplateSpan */; // `aa ${10} dd ${| case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: - return containingNodeKind === 163 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 164 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -121599,6 +125160,25 @@ var ts; return (ts.isRegularExpressionLiteral(contextToken) || ts.isStringTextContainingNode(contextToken)) && (ts.rangeContainsPositionExclusive(ts.createTextRangeFromSpan(ts.createTextSpanFromNode(contextToken)), position) || position === contextToken.end && (!!contextToken.isUnterminated || ts.isRegularExpressionLiteral(contextToken))); } + function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { + var typeLiteralNode = tryGetTypeLiteralNode(contextToken); + if (!typeLiteralNode) + return 0 /* Continue */; + var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; + var containerTypeNode = intersectionTypeNode || typeLiteralNode; + var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); + if (!containerExpectedType) + return 0 /* Continue */; + var containerActualType = typeChecker.getTypeFromTypeNode(containerTypeNode); + var members = getPropertiesForCompletion(containerExpectedType, typeChecker); + var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker); + var existingMemberEscapedNames = new ts.Set(); + existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); }); + symbols = ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); }); + completionKind = 0 /* ObjectPropertyDeclaration */; + isNewIdentifierLocation = true; + return 1 /* Success */; + } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. * Relevant symbols are stored in the captured 'symbols' variable. @@ -121613,7 +125193,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 200 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 201 /* ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { @@ -121638,7 +125218,7 @@ var ts; } } else { - ts.Debug.assert(objectLikeContainer.kind === 196 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 197 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -121649,12 +125229,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 === 239 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 160 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 240 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 161 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 165 /* MethodDeclaration */ || rootDeclaration.parent.kind === 168 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 166 /* MethodDeclaration */ || rootDeclaration.parent.kind === 169 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -121701,9 +125281,9 @@ var ts; if (!namedImportsOrExports) return 0 /* Continue */; // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 264 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 265 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) - return namedImportsOrExports.kind === 264 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 265 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -121771,12 +125351,16 @@ var ts; case "static": classElementModifierFlags = classElementModifierFlags | 32 /* Static */; break; + case "override": + classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + break; } } // No member list for private methods if (!(classElementModifierFlags & 8 /* Private */)) { // List of property symbols of base type that are not private and already implemented - var baseSymbols = ts.flatMap(ts.getAllSuperTypeNodes(decl), function (baseTypeNode) { + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); + var baseSymbols = ts.flatMap(baseTypeNodes, function (baseTypeNode) { var type = typeChecker.getTypeAtLocation(baseTypeNode); return classElementModifierFlags & 32 /* Static */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : @@ -121856,11 +125440,11 @@ var ts; case 30 /* LessThanSlashToken */: case 43 /* SlashToken */: case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: - case 281 /* JsxAttributes */: - case 280 /* JsxAttribute */: - case 282 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 274 /* JsxSelfClosingElement */ || parent.kind === 275 /* JsxOpeningElement */)) { + case 202 /* PropertyAccessExpression */: + case 282 /* JsxAttributes */: + case 281 /* JsxAttribute */: + case 283 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 275 /* JsxSelfClosingElement */ || parent.kind === 276 /* JsxOpeningElement */)) { if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) @@ -121868,7 +125452,7 @@ var ts; } return parent; } - else if (parent.kind === 280 /* JsxAttribute */) { + else if (parent.kind === 281 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121880,7 +125464,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 === 280 /* JsxAttribute */) || (parent.kind === 282 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 281 /* JsxAttribute */) || (parent.kind === 283 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121890,8 +125474,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 283 /* JsxExpression */ && - parent.parent && parent.parent.kind === 280 /* JsxAttribute */) { + parent.kind === 284 /* JsxExpression */ && + parent.parent && parent.parent.kind === 281 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121899,7 +125483,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 282 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 283 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -121919,49 +125503,49 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 249 /* VariableDeclaration */ || + return containingNodeKind === 250 /* VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 232 /* VariableStatement */ || - containingNodeKind === 255 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 233 /* VariableStatement */ || + containingNodeKind === 256 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 197 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 198 /* ArrayBindingPattern */; // var [.| case 58 /* ColonToken */: - return containingNodeKind === 198 /* BindingElement */; // var {x :html| + return containingNodeKind === 199 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 197 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 198 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 287 /* CatchClause */ || + return containingNodeKind === 288 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 255 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 256 /* EnumDeclaration */; // enum a { | case 29 /* LessThanToken */: - return containingNodeKind === 252 /* ClassDeclaration */ || // class A< | - containingNodeKind === 221 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 253 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 254 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 253 /* ClassDeclaration */ || // class A< | + containingNodeKind === 222 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 254 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 255 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 123 /* StaticKeyword */: - return containingNodeKind === 163 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + return containingNodeKind === 164 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 160 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 197 /* ArrayBindingPattern */); // var [...z| + return containingNodeKind === 161 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 198 /* ArrayBindingPattern */); // var [...z| case 122 /* PublicKeyword */: case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: - return containingNodeKind === 160 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + return containingNodeKind === 161 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 126 /* AsKeyword */: - return containingNodeKind === 265 /* ImportSpecifier */ || - containingNodeKind === 270 /* ExportSpecifier */ || - containingNodeKind === 263 /* NamespaceImport */; + return containingNodeKind === 266 /* ImportSpecifier */ || + containingNodeKind === 271 /* ExportSpecifier */ || + containingNodeKind === 264 /* NamespaceImport */; case 134 /* GetKeyword */: case 146 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); @@ -121979,7 +125563,7 @@ var ts; case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } - // If the previous token is keyword correspoding to class member completion keyword + // If the previous token is keyword corresponding to class member completion keyword // there will be completion available here if (isClassMemberCompletionKeyword(keywordForNode(contextToken)) && isFromObjectTypeDeclaration(contextToken)) { return false; @@ -122014,6 +125598,31 @@ var ts; case 129 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } + // If we are inside a class declaration, and `constructor` is totally not present, + // but we request a completion manually at a whitespace... + var ancestorClassLike = ts.findAncestor(contextToken.parent, ts.isClassLike); + if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { + return false; // Don't block completions. + } + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 164 /* PropertyDeclaration */); + // If we are inside a class declaration and typing `constructor` after property declaration... + if (ancestorPropertyDeclaraion + && contextToken !== previousToken + && ts.isClassLike(previousToken.parent.parent) + // And the cursor is at the token... + && position <= previousToken.end) { + // If we are sure that the previous property declaration is terminated according to newline or semicolon... + if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { + return false; // Don't block completions. + } + else if (contextToken.kind !== 62 /* EqualsToken */ + // Should not block: `class C { blah = c/**/ }` + // But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }` + && (ts.isInitializedProperty(ancestorPropertyDeclaraion) + || ts.hasType(ancestorPropertyDeclaraion))) { + return true; + } + } return ts.isDeclarationName(contextToken) && !ts.isShorthandPropertyAssignment(contextToken.parent) && !ts.isJsxAttribute(contextToken.parent) @@ -122021,8 +125630,13 @@ var ts; // If `contextToken !== previousToken`, this is `class C ex/**/`. && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } + function isPreviousPropertyDeclarationTerminated(contextToken, position) { + return contextToken.kind !== 62 /* EqualsToken */ && + (contextToken.kind === 26 /* SemicolonToken */ + || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); + } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 166 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 167 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -122032,7 +125646,7 @@ var ts; return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 250 /* VariableDeclarationList */ + return node.parent.kind === 251 /* VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -122050,13 +125664,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 !== 288 /* PropertyAssignment */ && - m.kind !== 289 /* ShorthandPropertyAssignment */ && - m.kind !== 198 /* BindingElement */ && - m.kind !== 165 /* MethodDeclaration */ && - m.kind !== 167 /* GetAccessor */ && - m.kind !== 168 /* SetAccessor */ && - m.kind !== 290 /* SpreadAssignment */) { + if (m.kind !== 289 /* PropertyAssignment */ && + m.kind !== 290 /* ShorthandPropertyAssignment */ && + m.kind !== 199 /* BindingElement */ && + m.kind !== 166 /* MethodDeclaration */ && + m.kind !== 168 /* GetAccessor */ && + m.kind !== 169 /* SetAccessor */ && + m.kind !== 291 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -122129,10 +125743,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 !== 163 /* PropertyDeclaration */ && - m.kind !== 165 /* MethodDeclaration */ && - m.kind !== 167 /* GetAccessor */ && - m.kind !== 168 /* SetAccessor */) { + if (m.kind !== 164 /* PropertyDeclaration */ && + m.kind !== 166 /* MethodDeclaration */ && + m.kind !== 168 /* GetAccessor */ && + m.kind !== 169 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -122156,7 +125770,7 @@ var ts; return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && - !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration)); + !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } /** @@ -122174,7 +125788,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 280 /* JsxAttribute */) { + if (attr.kind === 281 /* JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -122189,8 +125803,35 @@ var ts; return node.getStart(sourceFile) <= position && position <= node.getEnd(); } } + function getAutoImportSymbolFromCompletionEntryData(name, data, program, host) { + var containingProgram = data.isPackageJsonImport ? host.getPackageJsonAutoImportProvider() : program; + var checker = containingProgram.getTypeChecker(); + var moduleSymbol = data.ambientModuleName ? checker.tryFindAmbientModule(data.ambientModuleName) : + data.fileName ? checker.getMergedSymbol(ts.Debug.checkDefined(containingProgram.getSourceFile(data.fileName)).symbol) : + undefined; + if (!moduleSymbol) + return undefined; + var symbol = data.exportName === "export=" /* ExportEquals */ + ? checker.resolveExternalModuleSymbol(moduleSymbol) + : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); + if (!symbol) + 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, + } + }; + } function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, jsxIdentifierExpected) { - var name = originIsExport(origin) ? ts.getNameForExportedSymbol(symbol, target) : symbol.name; + var name = originIncludesSymbolName(origin) ? origin.symbolName : symbol.name; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) @@ -122200,7 +125841,7 @@ var ts; return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { @@ -122224,7 +125865,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 80 /* FirstKeyword */; i <= 156 /* LastKeyword */; i++) { + for (var i = 80 /* FirstKeyword */; i <= 157 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -122291,6 +125932,7 @@ var ts; case 141 /* NeverKeyword */: case 144 /* NumberKeyword */: case 145 /* ObjectKeyword */: + case 156 /* OverrideKeyword */: case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 122 /* PublicKeyword */: @@ -122316,6 +125958,7 @@ var ts; case 146 /* SetKeyword */: case 129 /* AsyncKeyword */: case 133 /* DeclareKeyword */: + case 156 /* OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); @@ -122376,7 +126019,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 334 /* SyntaxList */: + case 338 /* 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); @@ -122397,6 +126040,12 @@ var ts; } if (!contextToken) return undefined; + // class C { blah; constructor/**/ } and so on + if (location.kind === 132 /* ConstructorKeyword */ + // class C { blah \n constructor/**/ } + || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { + return ts.findAncestor(contextToken, ts.isClassLike); + } switch (contextToken.kind) { case 62 /* EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; @@ -122422,6 +126071,44 @@ var ts; ? contextToken.parent.parent : undefined; } } + function tryGetTypeLiteralNode(node) { + if (!node) + return undefined; + var parent = node.parent; + switch (node.kind) { + case 18 /* OpenBraceToken */: + if (ts.isTypeLiteralNode(parent)) { + return parent; + } + break; + case 26 /* SemicolonToken */: + case 27 /* CommaToken */: + case 78 /* Identifier */: + if (parent.kind === 163 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + return parent.parent; + } + break; + } + return undefined; + } + function getConstraintOfTypeArgumentProperty(node, checker) { + if (!node) + return undefined; + if (ts.isTypeNode(node) && ts.isTypeReferenceType(node.parent)) { + return checker.getTypeArgumentConstraint(node); + } + var t = getConstraintOfTypeArgumentProperty(node.parent, checker); + if (!t) + return undefined; + switch (node.kind) { + case 163 /* PropertySignature */: + return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); + case 184 /* IntersectionType */: + case 178 /* TypeLiteral */: + case 183 /* UnionType */: + return t; + } + } // TODO: GH#19856 Would like to return `node is Node & { parent: (ClassElement | TypeElement) & { parent: ObjectTypeDeclaration } }` but then compilation takes > 10 minutes function isFromObjectTypeDeclaration(node) { return node.parent && ts.isClassOrTypeElement(node.parent) && ts.isObjectTypeDeclaration(node.parent.parent); @@ -122445,6 +126132,8 @@ var ts; return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + case " ": + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 298 /* SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -122453,14 +126142,6 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } - function findAlias(typeChecker, symbol, predicate) { - var currentAlias = symbol; - while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { - if (predicate(currentAlias)) { - return currentAlias; - } - } - } /** Determines if a type is exactly the same type resolved by the global 'self', 'global', or 'globalThis'. */ function isProbablyGlobalType(type, sourceFile, checker) { // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in @@ -122487,11 +126168,67 @@ var ts; if (type) { return type; } - if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { + if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ && node === node.parent.left) { + // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(node.parent); } return undefined; } + function getImportCompletionNode(contextToken) { + var candidate = getCandidate(); + return candidate === 153 /* FromKeyword */ || candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined; + function getCandidate() { + var parent = contextToken.parent; + if (ts.isImportEqualsDeclaration(parent)) { + return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; + } + if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { + if (isModuleSpecifierMissingOrEmpty(parent.parent.parent.moduleSpecifier) && (ts.isNamespaceImport(parent) || parent.elements.length < 2) && !parent.parent.name) { + // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` + return contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 78 /* Identifier */ + ? 153 /* FromKeyword */ + : 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 + return contextToken; + } + if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { + // `import s| from` + return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; + } + return undefined; + } + } + function isModuleSpecifierMissingOrEmpty(specifier) { + var _a; + if (ts.nodeIsMissing(specifier)) + return true; + return !((_a = ts.tryCast(ts.isExternalModuleReference(specifier) ? specifier.expression : specifier, ts.isStringLiteralLike)) === null || _a === void 0 ? void 0 : _a.text); + } + function getVariableDeclaration(property) { + var variableDeclaration = ts.findAncestor(property, function (node) { + return ts.isFunctionBlock(node) || isArrowFunctionBody(node) || ts.isBindingPattern(node) + ? "quit" + : ts.isVariableDeclaration(node); + }); + return variableDeclaration; + } + function isArrowFunctionBody(node) { + return node.parent && ts.isArrowFunction(node.parent) && node.parent.body === node; + } + ; + /** True if symbol is a type or a module containing at least one type. */ + function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) { + if (seenModules === void 0) { seenModules = new ts.Map(); } + var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker); + return !!(sym.flags & 788968 /* Type */) || + !!(sym.flags & 1536 /* Module */) && + ts.addToSeen(seenModules, ts.getSymbolId(sym)) && + checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -122526,10 +126263,12 @@ var ts; if (!referenceEntries) return undefined; var map = ts.arrayToMultiMap(referenceEntries.map(ts.FindAllReferences.toHighlightSpan), function (e) { return e.fileName; }, function (e) { return e.span; }); - return ts.arrayFrom(map.entries(), function (_a) { + return ts.mapDefined(ts.arrayFrom(map.entries()), function (_a) { var fileName = _a[0], highlightSpans = _a[1]; if (!sourceFilesSet.has(fileName)) { - ts.Debug.assert(program.redirectTargetsMap.has(fileName)); + if (!program.redirectTargetsMap.has(fileName)) { + return undefined; + } var redirectTarget_1 = program.getSourceFile(fileName); var redirect = ts.find(sourceFilesToSearch, function (f) { return !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); fileName = redirect.fileName; @@ -122624,7 +126363,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 297 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 298 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -122656,16 +126395,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 244 /* SwitchStatement */: - if (statement.kind === 240 /* ContinueStatement */) { + case 245 /* SwitchStatement */: + if (statement.kind === 241 /* ContinueStatement */) { return false; } // falls through - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 237 /* WhileStatement */: + case 236 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -122681,11 +126420,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 257 /* ModuleBlock */: - case 297 /* SourceFile */: - case 230 /* Block */: - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 258 /* ModuleBlock */: + case 298 /* SourceFile */: + case 231 /* Block */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members), [declaration]); @@ -122693,14 +126432,14 @@ var ts; else { return container.statements; } - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 251 /* FunctionDeclaration */: + case 167 /* Constructor */: + case 166 /* MethodDeclaration */: + case 252 /* FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters), (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 177 /* TypeLiteral */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: + case 178 /* 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. @@ -122715,7 +126454,7 @@ var ts; } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -122736,7 +126475,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 96 /* ForKeyword */, 114 /* WhileKeyword */, 89 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 235 /* DoStatement */) { + if (loopNode.kind === 236 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 114 /* WhileKeyword */)) { @@ -122756,13 +126495,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -122935,6 +126674,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + function isDocumentRegistryEntry(entry) { + return !!entry.sourceFile; + } function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory); } @@ -122951,10 +126693,16 @@ var ts; var entries = buckets.get(name); var sourceFiles = []; entries.forEach(function (entry, name) { - sourceFiles.push({ - name: name, - refCount: entry.languageServiceRefCount - }); + if (isDocumentRegistryEntry(entry)) { + sourceFiles.push({ + name: name, + scriptKind: entry.sourceFile.scriptKind, + refCount: entry.languageServiceRefCount + }); + } + else { + entry.forEach(function (value, scriptKind) { return sourceFiles.push({ name: name, scriptKind: scriptKind, refCount: value.languageServiceRefCount }); }); + } }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { @@ -122980,10 +126728,17 @@ var ts; function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); } + function getDocumentRegistryEntry(bucketEntry, scriptKind) { + var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided")); + ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry); + return entry; + } function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) { - var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); - var entry = bucket.get(path); + scriptKind = ts.ensureScriptKind(fileName, scriptKind); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target || 1 /* ES5 */; + var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); + var bucketEntry = bucket.get(path); + var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); if (!entry && externalCache) { var sourceFile = externalCache.getDocument(key, path); if (sourceFile) { @@ -122992,7 +126747,7 @@ var ts; sourceFile: sourceFile, languageServiceRefCount: 0 }; - bucket.set(path, entry); + setBucketEntry(); } } if (!entry) { @@ -123005,7 +126760,7 @@ var ts; sourceFile: sourceFile, languageServiceRefCount: 1, }; - bucket.set(path, entry); + setBucketEntry(); } else { // We have an entry for this file. However, it may be for a different version of @@ -123028,25 +126783,49 @@ var ts; } ts.Debug.assert(entry.languageServiceRefCount !== 0); return entry.sourceFile; + function setBucketEntry() { + if (!bucketEntry) { + bucket.set(path, entry); + } + else if (isDocumentRegistryEntry(bucketEntry)) { + var scriptKindMap = new ts.Map(); + scriptKindMap.set(bucketEntry.sourceFile.scriptKind, bucketEntry); + scriptKindMap.set(scriptKind, entry); + bucket.set(path, scriptKindMap); + } + else { + bucketEntry.set(scriptKind, entry); + } + } } - function releaseDocument(fileName, compilationSettings) { + function releaseDocument(fileName, compilationSettings, scriptKind) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key); + return releaseDocumentWithKey(path, key, scriptKind); } - function releaseDocumentWithKey(path, key) { + function releaseDocumentWithKey(path, key, scriptKind) { var bucket = ts.Debug.checkDefined(buckets.get(key)); - var entry = bucket.get(path); + var bucketEntry = bucket.get(path); + var entry = getDocumentRegistryEntry(bucketEntry, scriptKind); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.delete(path); + if (isDocumentRegistryEntry(bucketEntry)) { + bucket.delete(path); + } + else { + bucketEntry.delete(scriptKind); + if (bucketEntry.size === 1) { + bucket.set(path, ts.firstDefinedIterator(bucketEntry.values(), ts.identity)); + } + } } } - function getLanguageServiceRefCounts(path) { + function getLanguageServiceRefCounts(path, scriptKind) { return ts.arrayFrom(buckets.entries(), function (_a) { var key = _a[0], bucket = _a[1]; - var entry = bucket.get(path); + var bucketEntry = bucket.get(path); + var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); return [key, entry && entry.languageServiceRefCount]; }); } @@ -123109,10 +126888,12 @@ var ts; return sourceFiles; } // Module augmentations may use this module's exports without importing it. - for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - if (ts.isExternalModuleAugmentation(decl) && sourceFilesSet.has(decl.getSourceFile().fileName)) { - addIndirectUser(decl); + if (exportingModuleSymbol.declarations) { + for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isExternalModuleAugmentation(decl) && sourceFilesSet.has(decl.getSourceFile().fileName)) { + addIndirectUser(decl); + } } } // This may return duplicates (if there are multiple module declarations in a single source file, all importing the same thing as a namespace), but `State.markSearchedSymbol` will handle that. @@ -123129,14 +126910,14 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 203 /* CallExpression */: + case 204 /* CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 249 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 250 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 78 /* Identifier */) { directImports.push(name); @@ -123147,25 +126928,25 @@ var ts; break; case 78 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 264 /* 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 267 /* ExportDeclaration */: + case 268 /* 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 === 269 /* NamespaceExport */) { + else if (direct.exportClause.kind === 270 /* NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -123174,7 +126955,7 @@ var ts; directImports.push(direct); } break; - case 195 /* ImportType */: + case 196 /* ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -123207,7 +126988,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 297 /* SourceFile */ || sourceFileLike.kind === 256 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 298 /* SourceFile */ || sourceFileLike.kind === 257 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -123263,7 +127044,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 260 /* ImportEqualsDeclaration */) { + if (decl.kind === 261 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -123273,7 +127054,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 195 /* ImportType */) { + if (decl.kind === 196 /* ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { @@ -123289,7 +127070,7 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 267 /* ExportDeclaration */) { + if (decl.kind === 268 /* ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -123298,10 +127079,10 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 264 /* NamedImports */: + case 265 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -123351,7 +127132,7 @@ var ts; } } else { - var localSymbol = element.kind === 270 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 271 /* 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); @@ -123380,7 +127161,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.kind === 297 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 298 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -123428,7 +127209,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 === 297 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 298 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -123443,15 +127224,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 267 /* ExportDeclaration */: - case 261 /* ImportDeclaration */: { + case 268 /* ExportDeclaration */: + case 262 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 260 /* ImportEqualsDeclaration */: { + case 261 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -123472,14 +127253,15 @@ var ts; function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { return comingFromExport ? getExport() : getExport() || getImport(); function getExport() { + var _a; var parent = node.parent; - var grandParent = parent.parent; + var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 201 /* PropertyAccessExpression */) { + if (parent.kind === 202 /* 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 symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) - ? getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ false) + return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) + ? getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ false) : undefined; } else { @@ -123509,15 +127291,15 @@ var ts; return getExportAssignmentExport(parent); } // If we are in `export = class A {};` (or `export = class A {};`) at `A`, `parent.parent` is the export assignment. - else if (ts.isExportAssignment(grandParent)) { - return getExportAssignmentExport(grandParent); + else if (ts.isExportAssignment(grandparent)) { + return getExportAssignmentExport(grandparent); } // Similar for `module.exports =` and `exports.A =`. else if (ts.isBinaryExpression(parent)) { return getSpecialPropertyExport(parent, /*useLhsSymbol*/ true); } - else if (ts.isBinaryExpression(grandParent)) { - return getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ true); + else if (ts.isBinaryExpression(grandparent)) { + return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { return exportInfo(symbol, 0 /* Named */); @@ -123525,9 +127307,10 @@ var ts; } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. - var exportingModuleSymbol = ts.Debug.checkDefined(ex.symbol.parent, "Expected export symbol to have a parent"); + if (!ex.symbol.parent) + return undefined; var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } }; + return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; @@ -123581,7 +127364,7 @@ var ts; if (importedSymbol.flags & 2097152 /* Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } - var decl = importedSymbol.valueDeclaration; + var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); if (ts.isExportAssignment(decl)) { // `export = class {}` return ts.Debug.checkDefined(decl.expression.symbol); } @@ -123608,17 +127391,17 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 265 /* ImportSpecifier */: + case 266 /* 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 262 /* ImportClause */: - case 263 /* NamespaceImport */: + case 263 /* ImportClause */: + case 264 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 198 /* BindingElement */: - return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent, /*requireStringLiteralLikeArgument*/ true); + case 199 /* BindingElement */: + return ts.isInJSFile(node) && ts.isRequireVariableDeclaration(parent); default: return false; } @@ -123642,7 +127425,8 @@ var ts; return checker.getExportSpecifierLocalTargetSymbol(declaration); } else if (ts.isPropertyAccessExpression(declaration) && ts.isModuleExportsAccessExpression(declaration.expression) && !ts.isPrivateIdentifier(declaration.name)) { - return checker.getExportSpecifierLocalTargetSymbol(declaration.name); + // Export of form 'module.exports.propName = expr'; + return checker.getSymbolAtLocation(declaration); } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) @@ -123657,21 +127441,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 203 /* CallExpression */) { + if (node.kind === 204 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 297 /* SourceFile */) { + if (parent.kind === 298 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 257 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 258 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 256 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 257 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 272 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 273 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -123774,7 +127558,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -123782,28 +127566,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 198 /* BindingElement */: + case 199 /* BindingElement */: return getContextNode(node.parent.parent); - case 265 /* ImportSpecifier */: + case 266 /* ImportSpecifier */: return node.parent.parent.parent; - case 270 /* ExportSpecifier */: - case 263 /* NamespaceImport */: + case 271 /* ExportSpecifier */: + case 264 /* NamespaceImport */: return node.parent.parent; - case 262 /* ImportClause */: - case 269 /* NamespaceExport */: + case 263 /* ImportClause */: + case 270 /* NamespaceExport */: return node.parent; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 239 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 289 /* PropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -123860,9 +127644,9 @@ var ts; var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 201 /* PropertyAccessExpression */ - || node.parent.kind === 198 /* BindingElement */ - || node.parent.kind === 202 /* ElementAccessExpression */ + if (node.parent.kind === 202 /* PropertyAccessExpression */ + || node.parent.kind === 199 /* BindingElement */ + || node.parent.kind === 203 /* ElementAccessExpression */ || node.kind === 105 /* SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries); } @@ -123886,13 +127670,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 297 /* SourceFile */) { + if (node.kind === 298 /* 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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 290 /* ShorthandPropertyAssignment */) { var result_1 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; @@ -124067,13 +127851,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 200 /* ObjectLiteralExpression */) { + else if (node.kind === 201 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 221 /* ClassExpression */) { + else if (node.kind === 222 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -124134,47 +127918,47 @@ var ts; if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 216 /* BinaryExpression */: - case 198 /* BindingElement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 217 /* BinaryExpression */: + case 199 /* BindingElement */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: case 87 /* DefaultKeyword */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 270 /* ExportSpecifier */: - case 262 /* ImportClause */: // default import - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 253 /* InterfaceDeclaration */: - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: - case 280 /* JsxAttribute */: - case 256 /* ModuleDeclaration */: - case 259 /* NamespaceExportDeclaration */: - case 263 /* NamespaceImport */: - case 269 /* NamespaceExport */: - case 160 /* Parameter */: - case 289 /* ShorthandPropertyAssignment */: - case 254 /* TypeAliasDeclaration */: - case 159 /* TypeParameter */: + case 256 /* EnumDeclaration */: + case 292 /* EnumMember */: + case 271 /* ExportSpecifier */: + case 263 /* ImportClause */: // default import + case 261 /* ImportEqualsDeclaration */: + case 266 /* ImportSpecifier */: + case 254 /* InterfaceDeclaration */: + case 328 /* JSDocCallbackTag */: + case 335 /* JSDocTypedefTag */: + case 281 /* JsxAttribute */: + case 257 /* ModuleDeclaration */: + case 260 /* NamespaceExportDeclaration */: + case 264 /* NamespaceImport */: + case 270 /* NamespaceExport */: + case 161 /* Parameter */: + case 290 /* ShorthandPropertyAssignment */: + case 255 /* TypeAliasDeclaration */: + case 160 /* TypeParameter */: return true; - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 166 /* Constructor */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 167 /* Constructor */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return !!decl.body; - case 249 /* VariableDeclaration */: - case 163 /* PropertyDeclaration */: + case 250 /* VariableDeclaration */: + case 164 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 164 /* MethodSignature */: - case 162 /* PropertySignature */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: + case 165 /* MethodSignature */: + case 163 /* PropertySignature */: + case 337 /* JSDocPropertyTag */: + case 330 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -124196,7 +127980,7 @@ var ts; } if (ts.isSourceFile(node)) { var resolvedRef = ts.GoToDefinition.getReferenceAtPosition(node, position, program); - if (!resolvedRef) { + if (!(resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file)) { return undefined; } var moduleSymbol = program.getTypeChecker().getMergedSymbol(resolvedRef.file.symbol); @@ -124225,7 +128009,7 @@ var ts; if (!symbol) { // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. if (!options.implementations && ts.isStringLiteralLike(node)) { - if (ts.isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ true) || ts.isExternalModuleReference(node.parent) || ts.isImportDeclaration(node.parent) || ts.isImportCall(node.parent)) { + 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 referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; @@ -124326,7 +128110,7 @@ var ts; result = references; continue; } - var _loop_3 = function (entry) { + var _loop_4 = function (entry) { if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { result.push(entry); return "continue"; @@ -124358,7 +128142,7 @@ var ts; }; for (var _b = 0, references_2 = references; _b < references_2.length; _b++) { var entry = references_2[_b]; - _loop_3(entry); + _loop_4(entry); } } return result; @@ -124395,10 +128179,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 297 /* SourceFile */: + case 298 /* 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 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } @@ -124410,7 +128194,7 @@ var ts; } } var exported = symbol.exports.get("export=" /* ExportEquals */); - if (exported) { + if (exported === null || exported === void 0 ? void 0 : exported.declarations) { for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { var decl = _c[_b]; var sourceFile = decl.getSourceFile(); @@ -124473,14 +128257,14 @@ var ts; var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; var result = []; var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); - var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); + var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) || !symbol.declarations ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); if (exportSpecifier) { // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 87 /* DefaultKeyword */) { + else if (node && node.kind === 87 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.checkDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state); } else { var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); @@ -124506,7 +128290,7 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 166 /* Constructor */: + case 167 /* Constructor */: case 132 /* ConstructorKeyword */: return 1 /* Constructor */; case 78 /* Identifier */: @@ -124637,8 +128421,8 @@ var ts; var sourceId = ts.getNodeId(sourceFile); var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set()); var anyNewSymbols = false; - for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { - var sym = symbols_3[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var sym = symbols_2[_i]; anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols; } return anyNewSymbols; @@ -124695,7 +128479,9 @@ var ts; for (var _c = 0, _d = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _c < _d.length; _c++) { var node = _d[_c]; // Import specifiers should be handled by importSearches - if (ts.isIdentifier(node) && !ts.isImportOrExportSpecifier(node.parent) && checker.getSymbolAtLocation(node) === exportSymbol) { + var symbol = checker.getSymbolAtLocation(node); + var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; }); + if (ts.isIdentifier(node) && !ts.isImportOrExportSpecifier(node.parent) && (symbol === exportSymbol || hasExportAssignmentDeclaration)) { cb(node); } } @@ -124747,7 +128533,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 === 208 /* FunctionExpression */ || valueDeclaration.kind === 221 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 209 /* FunctionExpression */ || valueDeclaration.kind === 222 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -124755,9 +128541,9 @@ var ts; } // If this is private property or method, the scope is the containing class if (flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierPropertyDeclaration(d); }); + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 252 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 253 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -124786,7 +128572,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 297 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 298 /* 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; @@ -125002,6 +128788,10 @@ var ts; default: ts.Debug.assertNever(state.specialSearchKind); } + // Use the parent symbol if the location is commonjs require syntax on javascript files only. + referenceSymbol = ts.isInJSFile(referenceLocation) && referenceLocation.parent.kind === 199 /* BindingElement */ && ts.isRequireVariableDeclaration(referenceLocation.parent) + ? referenceLocation.parent.symbol + : referenceSymbol; getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); } function getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, search, state, addReferencesHere, alwaysGetReferences) { @@ -125164,14 +128954,14 @@ var ts; for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 132 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 166 /* Constructor */ && !!ctrKeyword); + ts.Debug.assert(decl.kind === 167 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 165 /* MethodDeclaration */) { + if (decl && decl.kind === 166 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 107 /* ThisKeyword */, function (thisKeyword) { @@ -125195,7 +128985,7 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 166 /* Constructor */); + ts.Debug.assert(decl.kind === 167 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 105 /* SuperKeyword */, function (node) { @@ -125225,7 +129015,7 @@ var ts; if (refNode.kind !== 78 /* Identifier */) { return; } - if (refNode.parent.kind === 289 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 290 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -125245,7 +129035,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 230 /* Block */) { + if (body.kind === 231 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -125273,13 +129063,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 207 /* ParenthesizedExpression */: + case 208 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 200 /* ObjectLiteralExpression */: - case 221 /* ClassExpression */: - case 199 /* ArrayLiteralExpression */: + case 210 /* ArrowFunction */: + case 209 /* FunctionExpression */: + case 201 /* ObjectLiteralExpression */: + case 222 /* ClassExpression */: + case 200 /* ArrayLiteralExpression */: return true; default: return false; @@ -125332,13 +129122,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -125359,41 +129149,43 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 78 /* Identifier */ && node.parent.kind === 160 /* Parameter */ && node.parent.name === node; + return node.kind === 78 /* Identifier */ && node.parent.kind === 161 /* 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 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { + staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 297 /* SourceFile */: + case 298 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 209 /* 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 === 297 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 298 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -125401,19 +129193,20 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 221 /* ClassExpression */: - case 252 /* ClassDeclaration */: - // Make sure the container belongs to the same class + case 222 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 201 /* ObjectLiteralExpression */: + // Make sure the container belongs to the same class/object literals // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getSyntacticModifierFlags(container) & 32 /* Static */) === staticFlag; - case 297 /* SourceFile */: - return container.kind === 297 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 298 /* SourceFile */: + return container.kind === 298 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); @@ -125523,7 +129316,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, 270 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 271 /* ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { @@ -125568,7 +129361,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 198 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 199 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -125821,16 +129614,16 @@ var ts; return; } switch (node.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 165 /* MethodDeclaration */: - if (node.parent.kind === 200 /* ObjectLiteralExpression */) { + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 166 /* MethodDeclaration */: + if (node.parent.kind === 201 /* 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 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: + case 252 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: + case 257 /* ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -126036,55 +129829,55 @@ var ts; } switch (node.kind) { case 78 /* Identifier */: - case 260 /* ImportEqualsDeclaration */: - case 261 /* ImportDeclaration */: - case 267 /* ExportDeclaration */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 261 /* ImportEqualsDeclaration */: + case 262 /* ImportDeclaration */: + case 268 /* ExportDeclaration */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 206 /* TypeAssertionExpression */: - case 224 /* AsExpression */: + case 207 /* TypeAssertionExpression */: + case 225 /* AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: + case 250 /* VariableDeclaration */: + case 161 /* Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 203 /* CallExpression */: + case 204 /* CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 204 /* NewExpression */: + case 205 /* NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 205 /* TaggedTemplateExpression */: + case 206 /* TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 275 /* JsxOpeningElement */: - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxOpeningElement */: + case 275 /* JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 161 /* Decorator */: + case 162 /* Decorator */: recordCallSite(node); collect(node.expression); return; - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -126134,22 +129927,22 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 297 /* SourceFile */: + case 298 /* SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; default: @@ -126282,7 +130075,7 @@ var ts; } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) { var allFiles = program.getSourceFiles(); - var _loop_4 = function (sourceFile) { + var _loop_5 = function (sourceFile) { var newFromOld = oldToNew(sourceFile.fileName); var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); @@ -126299,7 +130092,7 @@ var ts; }, function (importLiteral) { var importedModuleSymbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); // No need to update if it's an ambient module^M - if (importedModuleSymbol && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + if ((importedModuleSymbol === null || importedModuleSymbol === void 0 ? void 0 : importedModuleSymbol.declarations) && importedModuleSymbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) return undefined; var toImport = oldFromNew !== undefined // If we're at the new location (file was already renamed), need to redo module resolution starting from the old location. @@ -126314,7 +130107,7 @@ var ts; }; for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { var sourceFile = allFiles_1[_i]; - _loop_4(sourceFile); + _loop_5(sourceFile); } } function combineNormal(pathA, pathB) { @@ -126405,8 +130198,10 @@ var ts; (function (GoToDefinition) { function getDefinitionAtPosition(program, sourceFile, position) { var resolvedRef = getReferenceAtPosition(sourceFile, position, program); - if (resolvedRef) { - return [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.file.fileName)]; + var fileReferenceDefinition = resolvedRef && [getDefinitionInfoForFileReference(resolvedRef.reference.fileName, resolvedRef.fileName, resolvedRef.unverified)] || ts.emptyArray; + if (resolvedRef === null || resolvedRef === void 0 ? void 0 : resolvedRef.file) { + // If `file` is missing, do a symbol-based lookup as well + return fileReferenceDefinition; } var node = ts.getTouchingPropertyName(sourceFile, position); if (node === sourceFile) { @@ -126423,7 +130218,7 @@ var ts; // Could not find a symbol e.g. node is string or number keyword, // or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!symbol) { - return getDefinitionInfoForIndexSignatures(node, typeChecker); + return ts.concatenate(fileReferenceDefinition, getDefinitionInfoForIndexSignatures(node, typeChecker)); } var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); // Don't go to the component constructor definition for a JSX element, just go to the component definition. @@ -126445,9 +130240,10 @@ 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 === 289 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 290 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); - return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; + 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); } // If the node is the name of a BindingElement within an ObjectBindingPattern instead of just returning the // declaration the symbol (which is itself), we should try to get to the original type of the ObjectBindingPattern @@ -126469,25 +130265,7 @@ var ts; return prop && getDefinitionFromSymbol(typeChecker, prop, node); }); } - // If the current location we want to find its definition is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. - // For example - // interface Props{ - // /*first*/prop1: number - // prop2: boolean - // } - // function Foo(arg: Props) {} - // Foo( { pr/*1*/op1: 10, prop2: true }) - var element = ts.getContainingObjectLiteralElement(node); - if (element) { - var contextualType = element && typeChecker.getContextualType(element.parent); - if (contextualType) { - return ts.flatMap(ts.getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), function (propertySymbol) { - return getDefinitionFromSymbol(typeChecker, propertySymbol, node); - }); - } - } - return getDefinitionFromSymbol(typeChecker, symbol, node); + return ts.concatenate(fileReferenceDefinition, getDefinitionFromObjectLiteralElement(typeChecker, node) || getDefinitionFromSymbol(typeChecker, symbol, node)); } GoToDefinition.getDefinitionAtPosition = getDefinitionAtPosition; /** @@ -126501,22 +130279,60 @@ var ts; || ts.isAssignmentExpression(calledDeclaration.parent) || (!ts.isCallLikeExpression(calledDeclaration.parent) && s === calledDeclaration.parent.symbol); } + // If the current location we want to find its definition is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. + // For example + // interface Props{ + // /*first*/prop1: number + // prop2: boolean + // } + // function Foo(arg: Props) {} + // Foo( { pr/*1*/op1: 10, prop2: true }) + function getDefinitionFromObjectLiteralElement(typeChecker, node) { + var element = ts.getContainingObjectLiteralElement(node); + if (element) { + var contextualType = element && typeChecker.getContextualType(element.parent); + if (contextualType) { + return ts.flatMap(ts.getPropertySymbolsFromContextualType(element, typeChecker, contextualType, /*unionSymbolOk*/ false), function (propertySymbol) { + return getDefinitionFromSymbol(typeChecker, propertySymbol, node); + }); + } + } + } function getReferenceAtPosition(sourceFile, position, program) { + var _a, _b; var referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); if (referencePath) { var file = program.getSourceFileFromReference(sourceFile, referencePath); - return file && { reference: referencePath, file: file }; + return file && { reference: referencePath, fileName: file.fileName, file: file, unverified: false }; } var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); var file = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217 - return file && { reference: typeReferenceDirective, file: file }; + return file && { reference: typeReferenceDirective, fileName: file.fileName, file: file, unverified: false }; } var libReferenceDirective = findReferenceInPosition(sourceFile.libReferenceDirectives, position); if (libReferenceDirective) { var file = program.getLibFileFromReference(libReferenceDirective); - return file && { reference: libReferenceDirective, file: file }; + return file && { reference: libReferenceDirective, fileName: file.fileName, file: file, unverified: false }; + } + 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; + var fileName = verifiedFileName || ts.resolvePath(ts.getDirectoryPath(sourceFile.fileName), node.text); + return { + file: program.getSourceFile(fileName), + fileName: fileName, + reference: { + pos: node.getStart(), + end: node.getEnd(), + fileName: node.text + }, + unverified: !verifiedFileName, + }; + } } return undefined; } @@ -126587,7 +130403,7 @@ var ts; // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if (symbol && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { return aliased; @@ -126608,14 +130424,14 @@ var ts; return true; } switch (declaration.kind) { - case 262 /* ImportClause */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportClause */: + case 261 /* ImportEqualsDeclaration */: return true; - case 265 /* ImportSpecifier */: - return declaration.parent.kind === 264 /* NamedImports */; - case 198 /* BindingElement */: - case 249 /* VariableDeclaration */: - return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration, /*requireStringLiteralLikeArgument*/ true); + case 266 /* ImportSpecifier */: + return declaration.parent.kind === 265 /* NamedImports */; + case 199 /* BindingElement */: + case 250 /* VariableDeclaration */: + return ts.isInJSFile(declaration) && ts.isRequireVariableDeclaration(declaration); default: return false; } @@ -126667,7 +130483,38 @@ var ts; var sourceFile = name.getSourceFile(); var textSpan = ts.createTextSpanFromNode(name, sourceFile); return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217 - containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !checker.isDeclarationVisible(declaration) }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration) }); + } + function isDefinitionVisible(checker, declaration) { + if (checker.isDeclarationVisible(declaration)) + return true; + if (!declaration.parent) + return false; + // Variable initializers are visible if variable is visible + if (ts.hasInitializer(declaration.parent) && declaration.parent.initializer === declaration) + return isDefinitionVisible(checker, declaration.parent); + // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent + switch (declaration.kind) { + case 164 /* PropertyDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 166 /* MethodDeclaration */: + // Private/protected properties/methods are not visible + if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + return false; + // Public properties/methods are visible if its parents are visible, so: + // falls through + case 167 /* Constructor */: + case 289 /* PropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: + case 201 /* ObjectLiteralExpression */: + case 222 /* ClassExpression */: + case 210 /* ArrowFunction */: + case 209 /* FunctionExpression */: + return isDefinitionVisible(checker, declaration.parent); + default: + return false; + } } function createDefinitionFromSignatureDeclaration(typeChecker, decl) { return createDefinitionInfo(decl, typeChecker, decl.symbol, decl); @@ -126676,14 +130523,15 @@ var ts; return ts.find(refs, function (ref) { return ts.textRangeContainsPositionInclusive(ref, pos); }); } GoToDefinition.findReferenceInPosition = findReferenceInPosition; - function getDefinitionInfoForFileReference(name, targetFileName) { + function getDefinitionInfoForFileReference(name, targetFileName, unverified) { return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), kind: "script" /* scriptElement */, name: name, containerName: undefined, - containerKind: undefined, // TODO: GH#18217 + containerKind: undefined, + unverified: unverified, }; } /** Returns a CallLikeExpression where `node` is the target being invoked. */ @@ -126700,9 +130548,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 166 /* Constructor */: - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 167 /* Constructor */: + case 176 /* ConstructorType */: + case 171 /* ConstructSignature */: return true; default: return false; @@ -126759,6 +130607,7 @@ var ts; "kind", "lends", "license", + "link", "listens", "member", "memberof", @@ -126796,78 +130645,115 @@ var ts; ]; var jsDocTagNameCompletionEntries; var jsDocTagCompletionEntries; - function getJsDocCommentsFromDeclarations(declarations) { + function getJsDocCommentsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times // which only varies in type parameter // Eg. const a: Array | Array; a.length // The property length will have two declarations of property length coming // from Array - Array and Array - var documentationComment = []; + var parts = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var comment = _a[_i].comment; if (comment === undefined) continue; - ts.pushIfUnique(documentationComment, comment); + var newparts = getDisplayPartsFromComment(comment, checker); + if (!ts.contains(parts, newparts, isIdenticalListOfDisplayParts)) { + parts.push(newparts); + } } }); - return ts.intersperse(ts.map(documentationComment, ts.textPart), ts.lineBreakPart()); + return ts.flatten(ts.intersperse(parts, [ts.lineBreakPart()])); } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function isIdenticalListOfDisplayParts(parts1, parts2) { + return ts.arraysEqual(parts1, parts2, function (p1, p2) { return p1.kind === p2.kind && p1.text === p2.text; }); + } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 326 /* JSDocParameterTag */: - case 333 /* JSDocPropertyTag */: + case 330 /* JSDocParameterTag */: + case 337 /* JSDocPropertyTag */: return [declaration]; - case 324 /* JSDocCallbackTag */: - case 331 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: + case 335 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); } } - function getJsDocTagsFromDeclarations(declarations) { + function getJsDocTagsFromDeclarations(declarations, checker) { // Only collect doc comments from duplicate declarations once. var tags = []; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = ts.getJSDocTags(declaration); _i < _a.length; _i++) { var tag = _a[_i]; - tags.push({ name: tag.tagName.text, text: getCommentText(tag) }); + tags.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) }); } }); return tags; } JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; - function getCommentText(tag) { - var comment = tag.comment; - switch (tag.kind) { - case 316 /* JSDocImplementsTag */: + function getDisplayPartsFromComment(comment, checker) { + if (typeof comment === "string") { + return [ts.textPart(comment)]; + } + return ts.flatMap(comment, function (node) { return node.kind === 313 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + } + function getCommentDisplayParts(tag, checker) { + var comment = tag.comment, kind = tag.kind; + var namePart = getTagNameDisplayPart(kind); + switch (kind) { + case 319 /* JSDocImplementsTag */: return withNode(tag.class); - case 315 /* JSDocAugmentsTag */: + case 318 /* JSDocAugmentsTag */: return withNode(tag.class); - case 330 /* JSDocTemplateTag */: - return withList(tag.typeParameters); - case 329 /* JSDocTypeTag */: + case 334 /* JSDocTemplateTag */: + return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", ")); + case 333 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: - case 332 /* JSDocSeeTag */: + case 335 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: + case 337 /* JSDocPropertyTag */: + case 330 /* JSDocParameterTag */: + case 336 /* JSDocSeeTag */: var name = tag.name; - return name ? withNode(name) : comment; + return name ? withNode(name) + : comment === undefined ? undefined + : getDisplayPartsFromComment(comment, checker); default: - return comment; + return comment === undefined ? undefined : getDisplayPartsFromComment(comment, checker); } function withNode(node) { return addComment(node.getText()); } - function withList(list) { - return addComment(list.map(function (x) { return x.getText(); }).join(", ")); - } function addComment(s) { - return comment === undefined ? s : s + " " + comment; + if (comment) { + if (s.match(/^https?$/)) { + return __spreadArray([ts.textPart(s)], getDisplayPartsFromComment(comment, checker)); + } + else { + return __spreadArray([namePart(s), ts.spacePart()], getDisplayPartsFromComment(comment, checker)); + } + } + else { + return [ts.textPart(s)]; + } + } + } + function getTagNameDisplayPart(kind) { + switch (kind) { + case 330 /* JSDocParameterTag */: + return ts.parameterNamePart; + case 337 /* JSDocPropertyTag */: + return ts.propertyNamePart; + case 334 /* JSDocTemplateTag */: + return ts.typeParameterNamePart; + case 335 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: + return ts.typeAliasNamePart; + default: + return ts.textPart; } } function getJSDocTagNameCompletions() { @@ -127028,24 +130914,24 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 164 /* MethodSignature */: - case 209 /* ArrowFunction */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 166 /* MethodDeclaration */: + case 167 /* Constructor */: + case 165 /* MethodSignature */: + case 210 /* ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 162 /* PropertySignature */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 254 /* TypeAliasDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 163 /* PropertySignature */: + case 256 /* EnumDeclaration */: + case 292 /* EnumMember */: + case 255 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 232 /* VariableStatement */: { + case 233 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -127055,16 +130941,16 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 297 /* SourceFile */: + case 298 /* SourceFile */: return "quit"; - case 256 /* ModuleDeclaration */: + case 257 /* 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 === 256 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 233 /* ExpressionStatement */: + return commentOwner.parent.kind === 257 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 234 /* ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 216 /* BinaryExpression */: { + case 217 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -127073,7 +130959,7 @@ var ts; ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -127086,14 +130972,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 === 207 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 208 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return rightHandSide; - case 221 /* ClassExpression */: + case 222 /* ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -127109,7 +130995,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_5 = function (sourceFile) { + var _loop_6 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && sourceFile.isDeclarationFile) { return "continue"; @@ -127121,7 +131007,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_5(sourceFile); + _loop_6(sourceFile); } rawItems.sort(compareNavigateToItems); return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); @@ -127152,9 +131038,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 262 /* ImportClause */: - case 265 /* ImportSpecifier */: - case 260 /* ImportEqualsDeclaration */: + case 263 /* ImportClause */: + case 266 /* ImportSpecifier */: + case 261 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -127164,7 +131050,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 158 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 159 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -127181,7 +131067,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 === 158 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 159 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -127391,6 +131277,18 @@ var ts; addNodeWithRecursiveChild(node, node.initializer); } } + /** + * Historically, we've elided dynamic names from the nav tree (including late bound names), + * but included certain "well known" symbol names. While we no longer distinguish those well-known + * symbols from other unique symbols, we do the below to retain those members in the nav tree. + */ + function hasNavigationBarName(node) { + return !ts.hasDynamicName(node) || + (node.kind !== 217 /* BinaryExpression */ && + ts.isPropertyAccessExpression(node.name.expression) && + ts.isIdentifier(node.name.expression.expression) && + ts.idText(node.name.expression.expression) === "Symbol"); + } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { var _a; @@ -127399,7 +131297,7 @@ var ts; return; } switch (node.kind) { - case 166 /* Constructor */: + case 167 /* 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); @@ -127411,25 +131309,25 @@ var ts; } } break; - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 164 /* MethodSignature */: - if (!ts.hasDynamicName(node)) { + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 165 /* MethodSignature */: + if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 163 /* PropertyDeclaration */: - if (!ts.hasDynamicName(node)) { + case 164 /* PropertyDeclaration */: + if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 162 /* PropertySignature */: - if (!ts.hasDynamicName(node)) { + case 163 /* PropertySignature */: + if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 262 /* ImportClause */: + case 263 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -127441,7 +131339,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings.kind === 264 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -127452,17 +131350,17 @@ var ts; } } break; - case 289 /* ShorthandPropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 290 /* SpreadAssignment */: + case 291 /* 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 198 /* BindingElement */: - case 288 /* PropertyAssignment */: - case 249 /* VariableDeclaration */: { + case 199 /* BindingElement */: + case 289 /* PropertyAssignment */: + case 250 /* VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -127472,7 +131370,7 @@ var ts; } break; } - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -127480,11 +131378,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 209 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -127494,9 +131392,9 @@ var ts; } endNode(); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -127504,10 +131402,10 @@ var ts; } endNode(); break; - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 266 /* ExportAssignment */: { + case 267 /* 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; @@ -127521,16 +131419,16 @@ var ts; } break; } - case 270 /* ExportSpecifier */: - case 260 /* ImportEqualsDeclaration */: - case 171 /* IndexSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 254 /* TypeAliasDeclaration */: + case 271 /* ExportSpecifier */: + case 261 /* ImportEqualsDeclaration */: + case 172 /* IndexSignature */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 255 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 203 /* CallExpression */: - case 216 /* BinaryExpression */: { + case 204 /* CallExpression */: + case 217 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -127772,13 +131670,14 @@ var ts; return false; } switch (a.kind) { - case 163 /* PropertyDeclaration */: - case 165 /* MethodDeclaration */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 164 /* PropertyDeclaration */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return ts.hasSyntacticModifier(a, 32 /* Static */) === ts.hasSyntacticModifier(b, 32 /* Static */); - case 256 /* ModuleDeclaration */: - return areSameModule(a, b); + case 257 /* ModuleDeclaration */: + return areSameModule(a, b) + && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: return true; } @@ -127795,8 +131694,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) { - // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 256 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 257 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -127826,7 +131724,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 256 /* ModuleDeclaration */) { + if (node.kind === 257 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -127835,16 +131733,16 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 221 /* ClassExpression */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 222 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 256 /* ModuleDeclaration */) { + if (node.kind === 257 /* ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { @@ -127856,18 +131754,18 @@ var ts; } } switch (node.kind) { - case 297 /* SourceFile */: + case 298 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: + case 210 /* ArrowFunction */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -127875,13 +131773,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 166 /* Constructor */: + case 167 /* Constructor */: return "constructor"; - case 170 /* ConstructSignature */: + case 171 /* ConstructSignature */: return "new()"; - case 169 /* CallSignature */: + case 170 /* CallSignature */: return "()"; - case 171 /* IndexSignature */: + case 172 /* IndexSignature */: return "[]"; default: return ""; @@ -127914,19 +131812,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 255 /* EnumDeclaration */: - case 253 /* InterfaceDeclaration */: - case 256 /* ModuleDeclaration */: - case 297 /* SourceFile */: - case 254 /* TypeAliasDeclaration */: - case 331 /* JSDocTypedefTag */: - case 324 /* JSDocCallbackTag */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 256 /* EnumDeclaration */: + case 254 /* InterfaceDeclaration */: + case 257 /* ModuleDeclaration */: + case 298 /* SourceFile */: + case 255 /* TypeAliasDeclaration */: + case 335 /* JSDocTypedefTag */: + case 328 /* JSDocCallbackTag */: return true; - case 209 /* ArrowFunction */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -127936,10 +131834,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 257 /* ModuleBlock */: - case 297 /* SourceFile */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: + case 258 /* ModuleBlock */: + case 298 /* SourceFile */: + case 166 /* MethodDeclaration */: + case 167 /* Constructor */: return true; default: return false; @@ -127996,9 +131894,12 @@ var ts; if (ts.isAmbientModule(moduleDeclaration)) { return ts.getTextOfNode(moduleDeclaration.name); } + return getFullyQualifiedModuleName(moduleDeclaration); + } + 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 === 256 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 257 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -128012,13 +131913,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 158 /* ComputedPropertyName */; + return !member.name || member.name.kind === 159 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 297 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 298 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 249 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 250 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -128076,9 +131977,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: - case 221 /* ClassExpression */: + case 210 /* ArrowFunction */: + case 209 /* FunctionExpression */: + case 222 /* ClassExpression */: return true; default: return false; @@ -128107,9 +132008,9 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, preferences) { + function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) { var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); - var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); }; + var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); organizeImportsWorker(topLevelImportDecls, coalesceAndOrganizeImports); @@ -128144,26 +132045,35 @@ var ts; ? coalesce(importGroup) : importGroup; }); - // Delete or replace the first import. + // Delete all nodes if there are no imports. if (newImportDecls.length === 0) { - changeTracker.delete(sourceFile, oldImportDecls[0]); + // Consider the first node to have trailingTrivia as we want to exclude the + // "header" comment. + changeTracker.deleteNodes(sourceFile, oldImportDecls, { + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, + }, /*hasTrailingComment*/ true); } else { // Note: Delete the surrounding trivia because it will have been retained in newImportDecls. - changeTracker.replaceNodeWithNodes(sourceFile, oldImportDecls[0], newImportDecls, { + var replaceOptions = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, suffix: ts.getNewLineOrDefaultFromHost(host, formatContext.options), - }); - } - // Delete any subsequent imports. - for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.deleteNode(sourceFile, oldImportDecls[i]); + }; + changeTracker.replaceNodeWithNodes(sourceFile, oldImportDecls[0], newImportDecls, replaceOptions); + var hasTrailingComment = changeTracker.nodeHasTrailingComment(sourceFile, oldImportDecls[0], replaceOptions); + changeTracker.deleteNodes(sourceFile, oldImportDecls.slice(1), { + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Include, + }, hasTrailingComment); } } } OrganizeImports.organizeImports = organizeImports; - function removeUnusedImports(oldImports, sourceFile, program) { + function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) { + // As a precaution, consider unused import detection to be destructive (GH #43051) + if (skipDestructiveCodeActions) { + return oldImports; + } var typeChecker = program.getTypeChecker(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); @@ -128434,11 +132344,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: return declaration.moduleSpecifier; - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -128477,19 +132387,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 261 /* ImportDeclaration */: + case 262 /* 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) === 263 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 264 /* NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return 5; - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return 6; } } @@ -128645,7 +132555,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 230 /* Block */: + case 231 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -128653,16 +132563,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 235 /* DoStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 234 /* IfStatement */: - case 236 /* WhileStatement */: - case 243 /* WithStatement */: - case 287 /* CatchClause */: + case 236 /* DoStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 238 /* ForStatement */: + case 235 /* IfStatement */: + case 237 /* WhileStatement */: + case 244 /* WithStatement */: + case 288 /* CatchClause */: return spanForNode(n.parent); - case 247 /* TryStatement */: + case 248 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -128679,40 +132589,40 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 257 /* ModuleBlock */: + case 258 /* ModuleBlock */: return spanForNode(n.parent); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 258 /* CaseBlock */: - case 177 /* TypeLiteral */: - case 196 /* ObjectBindingPattern */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: + case 256 /* EnumDeclaration */: + case 259 /* CaseBlock */: + case 178 /* TypeLiteral */: + case 197 /* ObjectBindingPattern */: return spanForNode(n); - case 179 /* TupleType */: + case 180 /* TupleType */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: return spanForNodeArray(n.statements); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 273 /* JsxElement */: + case 274 /* JsxElement */: return spanForJSXElement(n); - case 277 /* JsxFragment */: + case 278 /* JsxFragment */: return spanForJSXFragment(n); - case 274 /* JsxSelfClosingElement */: - case 275 /* JsxOpeningElement */: + case 275 /* JsxSelfClosingElement */: + case 276 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 218 /* TemplateExpression */: + case 219 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 197 /* ArrayBindingPattern */: + case 198 /* ArrayBindingPattern */: return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return spanForArrowFunction(n); - case 203 /* CallExpression */: + case 204 /* CallExpression */: return spanForCallExpression(n); } function spanForCallExpression(node) { @@ -128779,7 +132689,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 !== 209 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 210 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -129082,15 +132992,15 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_6 = function (start) { + var _loop_7 = 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_1 = _loop_6(start); - if (typeof state_1 === "object") - return state_1.value; + var state_2 = _loop_7(start); + if (typeof state_2 === "object") + return state_2.value; } return -1; } @@ -129642,7 +133552,7 @@ var ts; function getRenameInfo(program, sourceFile, position, options) { var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position)); if (nodeIsEligibleForRename(node)) { - var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, function (declaration) { return program.isSourceFileDefaultLibrary(declaration.getSourceFile()); }, options); + var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options); if (renameInfo) { return renameInfo; } @@ -129650,7 +133560,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element); } Rename.getRenameInfo = getRenameInfo; - function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile, options) { + function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) { var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { if (ts.isStringLiteralLike(node)) { @@ -129670,7 +133580,7 @@ var ts; if (!declarations || declarations.length === 0) return; // Disallow rename for elements that are defined in the standard TypeScript library. - if (declarations.some(isDefinedInLibraryFile)) { + if (declarations.some(function (declaration) { return isDefinedInLibraryFile(program, declaration); })) { return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; @@ -129681,18 +133591,22 @@ 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 === 158 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 159 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); var fullDisplayName = specifierName || typeChecker.getFullyQualifiedName(symbol); return getRenameInfoSuccess(displayName, fullDisplayName, kind, ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol), node, sourceFile); } + function isDefinedInLibraryFile(program, declaration) { + var sourceFile = declaration.getSourceFile(); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + } function getRenameInfoForModule(node, sourceFile, moduleSymbol) { if (!ts.isExternalModuleNameRelative(node.text)) { return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import); } - var moduleSourceFile = ts.find(moduleSymbol.declarations, ts.isSourceFile); + var moduleSourceFile = moduleSymbol.declarations && ts.find(moduleSymbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); @@ -129773,6 +133687,10 @@ var ts; if (ts.getTokenPosOfNode(node, sourceFile, /*includeJsDoc*/ true) > pos) { break outer; } + var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); + if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + pushSelectionCommentRange(comment.pos, comment.end); + } if (positionShouldSnapToNode(sourceFile, pos, node)) { // 1. Blocks are effectively redundant with SyntaxLists. // 2. TemplateSpans, along with the SyntaxLists containing them, are a somewhat unintuitive grouping @@ -129835,6 +133753,14 @@ var ts; } } } + function pushSelectionCommentRange(start, end) { + pushSelectionRange(start, end); + var pos = start; + while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + pos++; + } + pushSelectionRange(pos, end); + } } SmartSelectionRange.getSmartSelectionRange = getSmartSelectionRange; /** @@ -129898,7 +133824,7 @@ var ts; var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 159 /* TypeParameter */ || + kind === 160 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -130012,22 +133938,22 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 275 /* JsxOpeningElement */; + || kind === 276 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 276 /* JsxClosingElement */; + || kind === 277 /* JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 326 /* JSDocParameterTag */: - case 324 /* JSDocCallbackTag */: - case 333 /* JSDocPropertyTag */: - case 331 /* JSDocTypedefTag */: - case 328 /* JSDocThisTag */: + case 330 /* JSDocParameterTag */: + case 328 /* JSDocCallbackTag */: + case 337 /* JSDocPropertyTag */: + case 335 /* JSDocTypedefTag */: + case 332 /* JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -130237,10 +134163,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 205 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 206 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 218 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 219 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -130309,17 +134235,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 207 /* ParenthesizedExpression */: - case 165 /* MethodDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 208 /* ParenthesizedExpression */: + case 166 /* MethodDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* 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 216 /* BinaryExpression */: { + case 217 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -130443,7 +134369,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 === 218 /* TemplateExpression */) { + if (template.kind === 219 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -130452,7 +134378,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) { - var _loop_7 = function (n) { + var _loop_8 = 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); }); @@ -130462,9 +134388,9 @@ var ts; } }; for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) { - var state_2 = _loop_7(n); - if (typeof state_2 === "object") - return state_2.value; + var state_3 = _loop_8(n); + if (typeof state_3 === "object") + return state_3.value; } return undefined; } @@ -130541,7 +134467,7 @@ var ts; var printer = ts.createPrinter({ removeComments: true }); var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); - var tags = symbol.getJsDocTags(); + var tags = symbol.getJsDocTags(checker); var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay), [ts.punctuationPart(29 /* LessThanToken */)]); return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } @@ -130826,7 +134752,7 @@ var ts; diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); } } - if (ts.isFunctionLikeDeclaration(node)) { + if (canBeConvertedToAsync(node)) { addConvertToAsyncFunctionDiagnostics(node, checker, diags); } node.forEachChild(check); @@ -130837,11 +134763,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 233 /* ExpressionStatement */: { + case 234 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -130858,12 +134784,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 263 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 264 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -130883,11 +134809,11 @@ var ts; returnsPromise(node, checker); } function returnsPromise(node, checker) { - var functionType = checker.getTypeAtLocation(node); - var callSignatures = checker.getSignaturesOfType(functionType, 0 /* Call */); - var returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : undefined; + var signature = checker.getSignatureFromDeclaration(node); + var returnType = signature ? checker.getReturnTypeOfSignature(signature) : undefined; return !!returnType && !!checker.getPromisedTypeOfPromise(returnType); } + ts.returnsPromise = returnsPromise; function getErrorNodeFromCommonJsIndicator(commonJsModuleIndicator) { return ts.isBinaryExpression(commonJsModuleIndicator) ? commonJsModuleIndicator.left : commonJsModuleIndicator; } @@ -130932,15 +134858,15 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through case 103 /* NullKeyword */: return true; case 78 /* Identifier */: - case 201 /* PropertyAccessExpression */: { + case 202 /* PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -130957,18 +134883,30 @@ var ts; } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 208 /* FunctionExpression */) { + if (node.kind === 209 /* 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 === 251 /* FunctionDeclaration */) { + if (node.kind === 252 /* FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } + function canBeConvertedToAsync(node) { + switch (node.kind) { + case 252 /* FunctionDeclaration */: + case 166 /* MethodDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + return true; + default: + return false; + } + } + ts.canBeConvertedToAsync = canBeConvertedToAsync; })(ts || (ts = {})); /* @internal */ var ts; @@ -130984,7 +134922,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 222 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -131068,11 +135006,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 275 /* JsxOpeningElement */: - case 273 /* JsxElement */: - case 274 /* JsxSelfClosingElement */: + case 276 /* JsxOpeningElement */: + case 274 /* JsxElement */: + case 275 /* JsxSelfClosingElement */: return location.kind === 78 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 280 /* JsxAttribute */: + case 281 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -131118,6 +135056,7 @@ var ts; SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning, alias) { + var _a; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation = []; @@ -131141,8 +135080,8 @@ var ts; symbolKind = "property" /* memberVariableElement */; } var signature = void 0; - type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 201 /* PropertyAccessExpression */) { + type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); + if (location.parent && location.parent.kind === 202 /* 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)) { @@ -131162,9 +135101,9 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 204 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 105 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 205 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 105 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { + if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain // either the original signature or its target, so check for either signature = allSignatures.length ? allSignatures[0] : undefined; @@ -131226,7 +135165,7 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 132 /* ConstructorKeyword */ && location.parent.kind === 166 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 132 /* ConstructorKeyword */ && location.parent.kind === 167 /* 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 @@ -131234,24 +135173,26 @@ var ts; return declaration === (location.kind === 132 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 166 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 167 /* 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 === 166 /* Constructor */) { + if (functionDeclaration_1.kind === 167 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 169 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 170 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } - addSignatureDisplayParts(signature, allSignatures); + if (signature) { + addSignatureDisplayParts(signature, allSignatures); + } hasAddedSymbolInfo = true; hasMultipleSignatures = allSignatures.length > 1; } @@ -131259,7 +135200,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 221 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 222 /* 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 @@ -131303,7 +135244,7 @@ var ts; } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 256 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 257 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 78 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 140 /* NamespaceKeyword */ : 139 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -131324,7 +135265,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 159 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 160 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -131332,16 +135273,16 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 170 /* ConstructSignature */) { + if (declaration.kind === 171 /* ConstructSignature */) { displayParts.push(ts.keywordPart(102 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 169 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 170 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 254 /* TypeAliasDeclaration */) { + else if (declaration.kind === 255 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -131357,8 +135298,8 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); - var declaration = symbol.declarations[0]; - if (declaration.kind === 291 /* EnumMember */) { + var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 292 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -131388,31 +135329,33 @@ var ts; } else { documentationFromAlias = resolvedSymbol.getContextualDocumentationComment(resolvedNode, typeChecker); - tagsFromAlias = resolvedSymbol.getJsDocTags(); + tagsFromAlias = resolvedSymbol.getJsDocTags(typeChecker); } } } - switch (symbol.declarations[0].kind) { - case 259 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(140 /* NamespaceKeyword */)); - break; - case 266 /* ExportAssignment */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 87 /* DefaultKeyword */)); - break; - case 270 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); - break; - default: - displayParts.push(ts.keywordPart(99 /* ImportKeyword */)); + if (symbol.declarations) { + switch (symbol.declarations[0].kind) { + case 260 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(140 /* NamespaceKeyword */)); + break; + case 267 /* ExportAssignment */: + displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); + displayParts.push(ts.spacePart()); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 87 /* DefaultKeyword */)); + break; + case 271 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(92 /* ExportKeyword */)); + break; + default: + displayParts.push(ts.keywordPart(99 /* ImportKeyword */)); + } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 260 /* ImportEqualsDeclaration */) { + if (declaration.kind === 261 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -131499,10 +135442,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 && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 297 /* SourceFile */; })) { - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 216 /* BinaryExpression */) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 298 /* SourceFile */; })) { + for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + if (!declaration.parent || declaration.parent.kind !== 217 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -131510,7 +135453,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(typeChecker); - tags = rhsSymbol.getJsDocTags(); + tags = rhsSymbol.getJsDocTags(typeChecker); if (documentation.length > 0) { break; } @@ -131518,7 +135461,7 @@ var ts; } } if (tags.length === 0 && !hasMultipleSignatures) { - tags = symbol.getJsDocTags(); + tags = symbol.getJsDocTags(typeChecker); } if (documentation.length === 0 && documentationFromAlias) { documentation = documentationFromAlias; @@ -131620,16 +135563,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 208 /* FunctionExpression */) { + if (declaration.kind === 209 /* FunctionExpression */) { return true; } - if (declaration.kind !== 249 /* VariableDeclaration */ && declaration.kind !== 251 /* FunctionDeclaration */) { + if (declaration.kind !== 250 /* VariableDeclaration */ && declaration.kind !== 252 /* 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 === 297 /* SourceFile */ || parent.kind === 257 /* ModuleBlock */) { + if (parent.kind === 298 /* SourceFile */ || parent.kind === 258 /* ModuleBlock */) { return false; } } @@ -131735,7 +135678,7 @@ var ts; return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_8 = function (opt) { + var _loop_9 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -131754,7 +135697,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_8(opt); + _loop_9(opt); } return options; } @@ -131930,10 +135873,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 280 /* JsxAttribute */: - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: + case 281 /* JsxAttribute */: + case 276 /* JsxOpeningElement */: + case 277 /* JsxClosingElement */: + case 275 /* JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. return ts.isKeyword(node.kind) || node.kind === 78 /* Identifier */; } @@ -131941,14 +135884,7 @@ var ts; return false; } function shouldRescanJsxText(node) { - var isJSXText = ts.isJsxText(node); - if (isJSXText) { - var containingElement = ts.findAncestor(node.parent, function (p) { return ts.isJsxElement(p); }); - if (!containingElement) - return false; // should never happen - return !ts.isParenthesizedExpression(containingElement.parent); - } - return false; + return ts.isJsxText(node); } function shouldRescanSlashToken(container) { return container.kind === 13 /* RegularExpressionLiteral */; @@ -132045,7 +135981,7 @@ var ts; return scanner.scanJsxIdentifier(); case 5 /* RescanJsxText */: lastScanAction = 5 /* RescanJsxText */; - return scanner.reScanJsxToken(); + return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); case 6 /* RescanJsxAttributeValue */: lastScanAction = 6 /* RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); @@ -132134,7 +136070,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 156 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 157 /* LastToken */; token++) { if (token !== 1 /* EndOfFileToken */) { allTokens.push(token); } @@ -132149,9 +136085,9 @@ var ts; var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [3 /* MultiLineCommentTrivia */])); var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens), [1 /* EndOfFileToken */])); - var keywords = tokenRangeFromRange(80 /* FirstKeyword */, 156 /* LastKeyword */); + var keywords = tokenRangeFromRange(80 /* FirstKeyword */, 157 /* LastKeyword */); var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 77 /* LastBinaryOperator */); - var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 156 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; + var binaryKeywordOperators = [100 /* InKeyword */, 101 /* InstanceOfKeyword */, 157 /* OfKeyword */, 126 /* AsKeyword */, 137 /* IsKeyword */]; var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 78 /* Identifier */, 20 /* OpenParenToken */, @@ -132462,51 +136398,51 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 237 /* ForStatement */; + return context.contextNode.kind === 238 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 217 /* ConditionalExpression */: - case 184 /* ConditionalType */: - case 224 /* AsExpression */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 172 /* TypePredicate */: - case 182 /* UnionType */: - case 183 /* IntersectionType */: + case 218 /* ConditionalExpression */: + case 185 /* ConditionalType */: + case 225 /* AsExpression */: + case 271 /* ExportSpecifier */: + case 266 /* ImportSpecifier */: + case 173 /* TypePredicate */: + case 183 /* UnionType */: + case 184 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 198 /* BindingElement */: + case 199 /* BindingElement */: // equals in type X = ... // falls through - case 254 /* TypeAliasDeclaration */: + case 255 /* TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: // equal in let a = 0 // falls through - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: // equal in p = 0 // falls through - case 160 /* Parameter */: - case 291 /* EnumMember */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 161 /* Parameter */: + case 292 /* EnumMember */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 159 /* TypeParameter */: + case 160 /* TypeParameter */: return context.currentTokenSpan.kind === 100 /* InKeyword */ || context.nextTokenSpan.kind === 100 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 239 /* ForOfStatement */: - return context.currentTokenSpan.kind === 156 /* OfKeyword */ || context.nextTokenSpan.kind === 156 /* OfKeyword */; + case 240 /* ForOfStatement */: + return context.currentTokenSpan.kind === 157 /* OfKeyword */ || context.nextTokenSpan.kind === 157 /* OfKeyword */; } return false; } @@ -132518,22 +136454,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 163 /* PropertyDeclaration */ || - contextKind === 162 /* PropertySignature */ || - contextKind === 160 /* Parameter */ || - contextKind === 249 /* VariableDeclaration */ || + return contextKind === 164 /* PropertyDeclaration */ || + contextKind === 163 /* PropertySignature */ || + contextKind === 161 /* Parameter */ || + contextKind === 250 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 217 /* ConditionalExpression */ || - context.contextNode.kind === 184 /* ConditionalType */; + return context.contextNode.kind === 218 /* ConditionalExpression */ || + context.contextNode.kind === 185 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 196 /* ObjectBindingPattern */ || - context.contextNode.kind === 190 /* MappedType */ || + return context.contextNode.kind === 197 /* ObjectBindingPattern */ || + context.contextNode.kind === 191 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -132559,34 +136495,34 @@ var ts; return true; } switch (node.kind) { - case 230 /* Block */: - case 258 /* CaseBlock */: - case 200 /* ObjectLiteralExpression */: - case 257 /* ModuleBlock */: + case 231 /* Block */: + case 259 /* CaseBlock */: + case 201 /* ObjectLiteralExpression */: + case 258 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 252 /* FunctionDeclaration */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 169 /* CallSignature */: - case 208 /* FunctionExpression */: - case 166 /* Constructor */: - case 209 /* ArrowFunction */: + case 170 /* CallSignature */: + case 209 /* FunctionExpression */: + case 167 /* Constructor */: + case 210 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 253 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 254 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -132595,40 +136531,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 251 /* FunctionDeclaration */ || context.contextNode.kind === 208 /* FunctionExpression */; + return context.contextNode.kind === 252 /* FunctionDeclaration */ || context.contextNode.kind === 209 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 177 /* TypeLiteral */: - case 256 /* ModuleDeclaration */: - case 267 /* ExportDeclaration */: - case 268 /* NamedExports */: - case 261 /* ImportDeclaration */: - case 264 /* NamedImports */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: + case 256 /* EnumDeclaration */: + case 178 /* TypeLiteral */: + case 257 /* ModuleDeclaration */: + case 268 /* ExportDeclaration */: + case 269 /* NamedExports */: + case 262 /* ImportDeclaration */: + case 265 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 287 /* CatchClause */: - case 257 /* ModuleBlock */: - case 244 /* SwitchStatement */: + case 253 /* ClassDeclaration */: + case 257 /* ModuleDeclaration */: + case 256 /* EnumDeclaration */: + case 288 /* CatchClause */: + case 258 /* ModuleBlock */: + case 245 /* SwitchStatement */: return true; - case 230 /* Block */: { + case 231 /* 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 !== 209 /* ArrowFunction */ && blockParent.kind !== 208 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 210 /* ArrowFunction */ && blockParent.kind !== 209 /* FunctionExpression */) { return true; } } @@ -132637,32 +136573,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 234 /* IfStatement */: - case 244 /* SwitchStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 236 /* WhileStatement */: - case 247 /* TryStatement */: - case 235 /* DoStatement */: - case 243 /* WithStatement */: + case 235 /* IfStatement */: + case 245 /* SwitchStatement */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 237 /* WhileStatement */: + case 248 /* TryStatement */: + case 236 /* DoStatement */: + case 244 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 287 /* CatchClause */: + case 288 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 200 /* ObjectLiteralExpression */; + return context.contextNode.kind === 201 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 203 /* CallExpression */; + return context.contextNode.kind === 204 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 204 /* NewExpression */; + return context.contextNode.kind === 205 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -132677,10 +136613,10 @@ var ts; return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 209 /* ArrowFunction */; + return context.contextNode.kind === 210 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 195 /* ImportType */; + return context.contextNode.kind === 196 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; @@ -132689,19 +136625,19 @@ var ts; return context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 273 /* JsxElement */ && context.contextNode.kind !== 277 /* JsxFragment */; + return context.contextNode.kind !== 274 /* JsxElement */ && context.contextNode.kind !== 278 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 283 /* JsxExpression */ || context.contextNode.kind === 282 /* JsxSpreadAttribute */; + return context.contextNode.kind === 284 /* JsxExpression */ || context.contextNode.kind === 283 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 280 /* JsxAttribute */; + return context.nextTokenParent.kind === 281 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 280 /* JsxAttribute */; + return context.contextNode.kind === 281 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 274 /* JsxSelfClosingElement */; + return context.contextNode.kind === 275 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -132716,45 +136652,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 161 /* Decorator */; + return node.kind === 162 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 250 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 251 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 256 /* ModuleDeclaration */; + return context.contextNode.kind === 257 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 177 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 178 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 170 /* ConstructSignature */; + return context.contextNode.kind === 171 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 173 /* TypeReference */: - case 206 /* TypeAssertionExpression */: - case 254 /* TypeAliasDeclaration */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 223 /* ExpressionWithTypeArguments */: + case 174 /* TypeReference */: + case 207 /* TypeAssertionExpression */: + case 255 /* TypeAliasDeclaration */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: + case 224 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -132765,28 +136701,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 206 /* TypeAssertionExpression */; + return context.contextNode.kind === 207 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 113 /* VoidKeyword */ && context.currentTokenParent.kind === 212 /* VoidExpression */; + return context.currentTokenSpan.kind === 113 /* VoidKeyword */ && context.currentTokenParent.kind === 213 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 219 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 220 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 225 /* NonNullExpression */; + return context.contextNode.kind === 226 /* NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 234 /* IfStatement */: - case 237 /* ForStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 235 /* DoStatement */: - case 236 /* WhileStatement */: + case 235 /* IfStatement */: + case 238 /* ForStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 236 /* DoStatement */: + case 237 /* WhileStatement */: return true; default: return false; @@ -132811,12 +136747,12 @@ var ts; return nextTokenKind === 19 /* CloseBraceToken */ || nextTokenKind === 1 /* EndOfFileToken */; } - if (nextTokenKind === 229 /* SemicolonClassElement */ || + if (nextTokenKind === 230 /* SemicolonClassElement */ || nextTokenKind === 26 /* SemicolonToken */) { return false; } - if (context.contextNode.kind === 253 /* InterfaceDeclaration */ || - context.contextNode.kind === 254 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 254 /* InterfaceDeclaration */ || + context.contextNode.kind === 255 /* TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -132830,9 +136766,9 @@ var ts; if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 237 /* ForStatement */ - && context.currentTokenParent.kind !== 231 /* EmptyStatement */ - && context.currentTokenParent.kind !== 229 /* SemicolonClassElement */ + return context.currentTokenParent.kind !== 238 /* ForStatement */ + && context.currentTokenParent.kind !== 232 /* EmptyStatement */ + && context.currentTokenParent.kind !== 230 /* SemicolonClassElement */ && nextTokenKind !== 22 /* OpenBracketToken */ && nextTokenKind !== 20 /* OpenParenToken */ && nextTokenKind !== 39 /* PlusToken */ @@ -132840,7 +136776,7 @@ var ts; && nextTokenKind !== 43 /* SlashToken */ && nextTokenKind !== 13 /* RegularExpressionLiteral */ && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 218 /* TemplateExpression */ + && nextTokenKind !== 219 /* TemplateExpression */ && nextTokenKind !== 15 /* TemplateHead */ && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ && nextTokenKind !== 24 /* DotToken */; @@ -132931,12 +136867,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 156 /* LastKeyword */ && column <= 156 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 157 /* LastKeyword */ && column <= 157 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 156 /* LastToken */ + 1; + var mapRowLength = 157 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -133124,17 +137060,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 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 257 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 297 /* SourceFile */: - case 230 /* Block */: - case 257 /* ModuleBlock */: + return !!body && body.kind === 258 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 298 /* SourceFile */: + case 231 /* Block */: + case 258 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 287 /* CatchClause */: + case 288 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -133363,19 +137299,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 252 /* ClassDeclaration */: return 83 /* ClassKeyword */; - case 253 /* InterfaceDeclaration */: return 117 /* InterfaceKeyword */; - case 251 /* FunctionDeclaration */: return 97 /* FunctionKeyword */; - case 255 /* EnumDeclaration */: return 255 /* EnumDeclaration */; - case 167 /* GetAccessor */: return 134 /* GetKeyword */; - case 168 /* SetAccessor */: return 146 /* SetKeyword */; - case 165 /* MethodDeclaration */: + case 253 /* ClassDeclaration */: return 83 /* ClassKeyword */; + case 254 /* InterfaceDeclaration */: return 117 /* InterfaceKeyword */; + case 252 /* FunctionDeclaration */: return 97 /* FunctionKeyword */; + case 256 /* EnumDeclaration */: return 256 /* EnumDeclaration */; + case 168 /* GetAccessor */: return 134 /* GetKeyword */; + case 169 /* SetAccessor */: return 146 /* SetKeyword */; + case 166 /* MethodDeclaration */: if (node.asteriskToken) { return 41 /* AsteriskToken */; } // falls through - case 163 /* PropertyDeclaration */: - case 160 /* Parameter */: + case 164 /* PropertyDeclaration */: + case 161 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -133432,16 +137368,16 @@ var ts; case 43 /* SlashToken */: case 31 /* GreaterThanToken */: switch (container.kind) { - case 275 /* JsxOpeningElement */: - case 276 /* JsxClosingElement */: - case 274 /* JsxSelfClosingElement */: - case 223 /* ExpressionWithTypeArguments */: + case 276 /* JsxOpeningElement */: + case 277 /* JsxClosingElement */: + case 275 /* JsxSelfClosingElement */: + case 224 /* ExpressionWithTypeArguments */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 190 /* MappedType */) { + if (container.kind !== 191 /* MappedType */) { return false; } break; @@ -133486,11 +137422,6 @@ var ts; if (tokenInfo.token.end > node.end) { break; } - if (node.kind === 11 /* JsxText */) { - // Intentation rules for jsx text are handled by `indentMultilineCommentOrJsxText` inside `processChildNode`; just fastforward past it here - formattingScanner.advance(); - continue; - } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } if (!node.parent && formattingScanner.isOnEOF()) { @@ -133549,27 +137480,11 @@ var ts; return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 161 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 162 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); - if (child.kind === 11 /* JsxText */) { - var range = { pos: child.getStart(), end: child.getEnd() }; - if (range.pos !== range.end) { // don't indent zero-width jsx text - var siblings = parent.getChildren(sourceFile); - var currentIndex = ts.findIndex(siblings, function (arg) { return arg.pos === child.pos; }); - var previousNode = siblings[currentIndex - 1]; - if (previousNode) { - // The jsx text needs no indentation whatsoever if it ends on the same line the previous sibling ends on - if (sourceFile.getLineAndCharacterOfPosition(range.end).line !== sourceFile.getLineAndCharacterOfPosition(previousNode.end).line) { - // The first line is (already) "indented" if the text starts on the same line as the previous sibling element ends on - var firstLineIsIndented = sourceFile.getLineAndCharacterOfPosition(range.pos).line === sourceFile.getLineAndCharacterOfPosition(previousNode.end).line; - indentMultilineCommentOrJsxText(range, childIndentation.indentation, firstLineIsIndented, /*indentFinalLine*/ false, /*jsxStyle*/ true); - } - } - } - } childContextNode = node; - if (isFirstListItem && parent.kind === 199 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 200 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -133693,7 +137608,7 @@ var ts; switch (triviaItem.kind) { case 3 /* MultiLineCommentTrivia */: if (triviaInRange) { - indentMultilineCommentOrJsxText(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); + indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; @@ -133810,7 +137725,7 @@ var ts; function indentationIsDifferent(indentationString, startLinePosition) { return indentationString !== sourceFile.text.substr(startLinePosition, indentationString.length); } - function indentMultilineCommentOrJsxText(commentRange, indentation, firstLineIsIndented, indentFinalLine, jsxTextStyleIndent) { + function indentMultilineComment(commentRange, indentation, firstLineIsIndented, indentFinalLine) { if (indentFinalLine === void 0) { indentFinalLine = true; } // split comment in lines var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line; @@ -133848,13 +137763,6 @@ var ts; var nonWhitespaceCharacterAndColumn = i === 0 ? nonWhitespaceColumnInFirstPart : formatting.SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options); - if (jsxTextStyleIndent) { - // skip adding indentation to blank lines - if (ts.isLineBreak(sourceFile.text.charCodeAt(ts.getStartPositionOfLine(startLine, sourceFile)))) - continue; - // reset delta on every line - delta = indentation - nonWhitespaceCharacterAndColumn.column; - } var newIndentation = nonWhitespaceCharacterAndColumn.column + delta; if (newIndentation > 0) { var indentationString = getIndentationString(newIndentation, options); @@ -134009,12 +137917,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 166 /* Constructor */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 209 /* ArrowFunction */: + case 167 /* Constructor */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 210 /* ArrowFunction */: if (node.typeParameters === list) { return 29 /* LessThanToken */; } @@ -134022,8 +137930,8 @@ var ts; return 20 /* OpenParenToken */; } break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } @@ -134031,12 +137939,12 @@ var ts; return 20 /* OpenParenToken */; } break; - case 173 /* TypeReference */: + case 174 /* TypeReference */: if (node.typeArguments === list) { return 29 /* LessThanToken */; } break; - case 177 /* TypeLiteral */: + case 178 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -134154,7 +138062,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 216 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 217 /* 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 */) { @@ -134327,7 +138235,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 === 297 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 298 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -134375,7 +138283,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 234 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 235 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 90 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -134456,40 +138364,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 173 /* TypeReference */: + case 174 /* TypeReference */: return getList(node.typeArguments); - case 200 /* ObjectLiteralExpression */: + case 201 /* ObjectLiteralExpression */: return getList(node.properties); - case 199 /* ArrayLiteralExpression */: + case 200 /* ArrayLiteralExpression */: return getList(node.elements); - case 177 /* TypeLiteral */: + case 178 /* TypeLiteral */: return getList(node.members); - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 166 /* Constructor */: - case 175 /* ConstructorType */: - case 170 /* ConstructSignature */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 170 /* CallSignature */: + case 167 /* Constructor */: + case 176 /* ConstructorType */: + case 171 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 330 /* JSDocTemplateTag */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 334 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 204 /* NewExpression */: - case 203 /* CallExpression */: + case 205 /* NewExpression */: + case 204 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 250 /* VariableDeclarationList */: + case 251 /* VariableDeclarationList */: return getList(node.declarations); - case 264 /* NamedImports */: - case 268 /* NamedExports */: + case 265 /* NamedImports */: + case 269 /* NamedExports */: return getList(node.elements); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 197 /* ObjectBindingPattern */: + case 198 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -134512,7 +138420,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 250 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 251 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -134585,91 +138493,91 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 233 /* ExpressionStatement */: - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 199 /* ArrayLiteralExpression */: - case 230 /* Block */: - case 257 /* ModuleBlock */: - case 200 /* ObjectLiteralExpression */: - case 177 /* TypeLiteral */: - case 190 /* MappedType */: - case 179 /* TupleType */: - case 258 /* CaseBlock */: - case 285 /* DefaultClause */: - case 284 /* CaseClause */: - case 207 /* ParenthesizedExpression */: - case 201 /* PropertyAccessExpression */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 232 /* VariableStatement */: - case 266 /* ExportAssignment */: - case 242 /* ReturnStatement */: - case 217 /* ConditionalExpression */: - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: - case 275 /* JsxOpeningElement */: - case 278 /* JsxOpeningFragment */: - case 274 /* JsxSelfClosingElement */: - case 283 /* JsxExpression */: - case 164 /* MethodSignature */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 160 /* Parameter */: - case 174 /* FunctionType */: - case 175 /* ConstructorType */: - case 186 /* ParenthesizedType */: - case 205 /* TaggedTemplateExpression */: - case 213 /* AwaitExpression */: - case 268 /* NamedExports */: - case 264 /* NamedImports */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 163 /* PropertyDeclaration */: + case 234 /* ExpressionStatement */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: + case 256 /* EnumDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 200 /* ArrayLiteralExpression */: + case 231 /* Block */: + case 258 /* ModuleBlock */: + case 201 /* ObjectLiteralExpression */: + case 178 /* TypeLiteral */: + case 191 /* MappedType */: + case 180 /* TupleType */: + case 259 /* CaseBlock */: + case 286 /* DefaultClause */: + case 285 /* CaseClause */: + case 208 /* ParenthesizedExpression */: + case 202 /* PropertyAccessExpression */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: + case 233 /* VariableStatement */: + case 267 /* ExportAssignment */: + case 243 /* ReturnStatement */: + case 218 /* ConditionalExpression */: + case 198 /* ArrayBindingPattern */: + case 197 /* ObjectBindingPattern */: + case 276 /* JsxOpeningElement */: + case 279 /* JsxOpeningFragment */: + case 275 /* JsxSelfClosingElement */: + case 284 /* JsxExpression */: + case 165 /* MethodSignature */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 161 /* Parameter */: + case 175 /* FunctionType */: + case 176 /* ConstructorType */: + case 187 /* ParenthesizedType */: + case 206 /* TaggedTemplateExpression */: + case 214 /* AwaitExpression */: + case 269 /* NamedExports */: + case 265 /* NamedImports */: + case 271 /* ExportSpecifier */: + case 266 /* ImportSpecifier */: + case 164 /* PropertyDeclaration */: return true; - case 249 /* VariableDeclaration */: - case 288 /* PropertyAssignment */: - case 216 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 200 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 250 /* VariableDeclaration */: + case 289 /* PropertyAssignment */: + case 217 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 201 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind !== 216 /* BinaryExpression */) { + if (parent.kind !== 217 /* BinaryExpression */) { return true; } break; - case 235 /* DoStatement */: - case 236 /* WhileStatement */: - case 238 /* ForInStatement */: - case 239 /* ForOfStatement */: - case 237 /* ForStatement */: - case 234 /* IfStatement */: - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - return childKind !== 230 /* Block */; - case 209 /* ArrowFunction */: - if (sourceFile && childKind === 207 /* ParenthesizedExpression */) { + case 236 /* DoStatement */: + case 237 /* WhileStatement */: + case 239 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 238 /* ForStatement */: + case 235 /* IfStatement */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 166 /* MethodDeclaration */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + return childKind !== 231 /* Block */; + case 210 /* ArrowFunction */: + if (sourceFile && childKind === 208 /* ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 230 /* Block */; - case 267 /* ExportDeclaration */: - return childKind !== 268 /* NamedExports */; - case 261 /* ImportDeclaration */: - return childKind !== 262 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 264 /* NamedImports */); - case 273 /* JsxElement */: - return childKind !== 276 /* JsxClosingElement */; - case 277 /* JsxFragment */: - return childKind !== 279 /* JsxClosingFragment */; - case 183 /* IntersectionType */: - case 182 /* UnionType */: - if (childKind === 177 /* TypeLiteral */ || childKind === 179 /* TupleType */) { + return childKind !== 231 /* Block */; + case 268 /* ExportDeclaration */: + return childKind !== 269 /* NamedExports */; + case 262 /* ImportDeclaration */: + return childKind !== 263 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 265 /* NamedImports */); + case 274 /* JsxElement */: + return childKind !== 277 /* JsxClosingElement */; + case 278 /* JsxFragment */: + return childKind !== 280 /* JsxClosingFragment */; + case 184 /* IntersectionType */: + case 183 /* UnionType */: + if (childKind === 178 /* TypeLiteral */ || childKind === 180 /* TupleType */) { return false; } break; @@ -134680,11 +138588,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 242 /* ReturnStatement */: - case 246 /* ThrowStatement */: - case 240 /* ContinueStatement */: - case 241 /* BreakStatement */: - return parent.kind !== 230 /* Block */; + case 243 /* ReturnStatement */: + case 247 /* ThrowStatement */: + case 241 /* ContinueStatement */: + case 242 /* BreakStatement */: + return parent.kind !== 231 /* Block */; default: return false; } @@ -134792,7 +138700,9 @@ var ts; function getAdjustedRange(sourceFile, startNode, endNode, options) { return { pos: getAdjustedStartPosition(sourceFile, startNode, options), end: getAdjustedEndPosition(sourceFile, endNode, options) }; } - function getAdjustedStartPosition(sourceFile, node, options) { + function getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment) { + var _a, _b; + if (hasTrailingComment === void 0) { hasTrailingComment = false; } var leadingTriviaOption = options.leadingTriviaOption; if (leadingTriviaOption === LeadingTriviaOption.Exclude) { return node.getStart(sourceFile); @@ -134823,6 +138733,15 @@ var ts; // when b is deleted - we delete it return leadingTriviaOption === LeadingTriviaOption.IncludeAll ? fullStart : start; } + // if node has a trailing comments, use comment end position as the text has already been included. + if (hasTrailingComment) { + // Check first for leading comments as if the node is the first import, we want to exclude the trivia; + // otherwise we get the trailing comments. + var comment = ((_a = ts.getLeadingCommentRanges(sourceFile.text, fullStart)) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = ts.getTrailingCommentRanges(sourceFile.text, fullStart)) === null || _b === void 0 ? void 0 : _b[0]); + if (comment) { + return ts.skipTrivia(sourceFile.text, comment.end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ true); + } + } // get start position of the line following the line that contains fullstart position // (but only if the fullstart isn't the very beginning of the file) var nextLineStart = fullStart > 0 ? 1 : 0; @@ -134831,6 +138750,35 @@ var ts; adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); } + /** Return the end position of a multiline comment of it is on another line; otherwise returns `undefined`; */ + function getEndPositionOfMultilineTrailingComment(sourceFile, node, options) { + var end = node.end; + var trailingTriviaOption = options.trailingTriviaOption; + if (trailingTriviaOption === TrailingTriviaOption.Include) { + // If the trailing comment is a multiline comment that extends to the next lines, + // return the end of the comment and track it for the next nodes to adjust. + var comments = ts.getTrailingCommentRanges(sourceFile.text, end); + if (comments) { + var nodeEndLine = ts.getLineOfLocalPosition(sourceFile, node.end); + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var comment = comments_2[_i]; + // Single line can break the loop as trivia will only be this line. + // Comments on subsequest lines are also ignored. + if (comment.kind === 2 /* SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { + break; + } + // Get the end line of the comment and compare against the end line of the node. + // If the comment end line position and the multiline comment extends to multiple lines, + // then is safe to return the end position. + var commentEndLine = ts.getLineOfLocalPosition(sourceFile, comment.end); + if (commentEndLine > nodeEndLine) { + return ts.skipTrivia(sourceFile.text, comment.end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ true); + } + } + } + } + return undefined; + } function getAdjustedEndPosition(sourceFile, node, options) { var _a; var end = node.end; @@ -134846,6 +138794,10 @@ var ts; } return end; } + var multilineEndPosition = getEndPositionOfMultilineTrailingComment(sourceFile, node, options); + if (multilineEndPosition) { + return multilineEndPosition; + } var newEnd = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); return newEnd !== end && (trailingTriviaOption === TrailingTriviaOption.Include || ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1))) ? newEnd @@ -134855,14 +138807,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 === 200 /* ObjectLiteralExpression */)); - } - function spaces(count) { - var s = ""; - for (var i = 0; i < count; i++) { - s += " "; - } - return s; + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 201 /* ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -134908,6 +138853,17 @@ var ts; if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options)); }; + ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) { + if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } + // When deleting multiple nodes we need to track if the end position is including multiline trailing comments. + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment); + var end = getAdjustedEndPosition(sourceFile, node, options); + this.deleteRange(sourceFile, { pos: pos, end: end }); + hasTrailingComment = !!getEndPositionOfMultilineTrailingComment(sourceFile, node, options); + } + }; ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; @@ -134950,6 +138906,10 @@ var ts; if (options === void 0) { options = useNonAdjustedPositions; } this.replaceRangeWithNodes(sourceFile, getAdjustedRange(sourceFile, startNode, endNode, options), newNodes, options); }; + ChangeTracker.prototype.nodeHasTrailingComment = function (sourceFile, oldNode, configurableEnd) { + if (configurableEnd === void 0) { configurableEnd = useNonAdjustedPositions; } + return !!getEndPositionOfMultilineTrailingComment(sourceFile, oldNode, configurableEnd); + }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); return next && next.kind === 27 /* CommaToken */ ? next : undefined; @@ -135054,7 +139014,7 @@ var ts; } } else { - endNode = (_a = (node.kind === 249 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 250 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; @@ -135096,6 +139056,15 @@ var ts; this.insertNodeBefore(sourceFile, firstStatement, newStatement); } }; + ChangeTracker.prototype.insertNodeAtConstructorStartAfterSuperCall = function (sourceFile, ctr, newStatement) { + var superCallStatement = ts.find(ctr.body.statements, function (stmt) { return ts.isExpressionStatement(stmt) && ts.isSuperCall(stmt.expression); }); + if (!superCallStatement || !ctr.body.multiLine) { + this.replaceConstructorBody(sourceFile, ctr, __spreadArray(__spreadArray([], ctr.body.statements), [newStatement])); + } + else { + this.insertNodeAfter(sourceFile, superCallStatement, newStatement); + } + }; ChangeTracker.prototype.insertNodeAtConstructorEnd = function (sourceFile, ctr, newStatement) { var lastStatement = ts.lastOrUndefined(ctr.body.statements); if (!lastStatement || !ctr.body.multiLine) { @@ -135211,18 +139180,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: + case 253 /* ClassDeclaration */: + case 257 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: case 10 /* StringLiteral */: case 78 /* Identifier */: return { prefix: ", " }; - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; case 92 /* ExportKeyword */: return { prefix: " " }; - case 160 /* Parameter */: + case 161 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -135231,7 +139200,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 209 /* ArrowFunction */) { + if (node.kind === 210 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { @@ -135245,14 +139214,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 !== 230 /* Block */) { + if (node.body.kind !== 231 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(104 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 208 /* FunctionExpression */ ? 97 /* FunctionKeyword */ : 83 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 209 /* FunctionExpression */ ? 97 /* FunctionKeyword */ : 83 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -135284,47 +139253,22 @@ var ts; // a, b, c // create change for adding 'e' after 'a' as // - find start of next element after a (it is b) - // - use this start as start and end position in final change - // - build text of change by formatting the text of node + separator + whitespace trivia of b + // - use next element start as start and end position in final change + // - build text of change by formatting the text of node + whitespace trivia of b // in multiline case it will work as // a, // b, // c, // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') - // a,* - // ***insertedtext# + // a, + // insertedtext# // ###b, // c, - // find line and character of the next element - var lineAndCharOfNextElement = ts.getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); - // find line and character of the token that precedes next element (usually it is separator) - var lineAndCharOfNextToken = ts.getLineAndCharacterOfPosition(sourceFile, nextToken.end); - var prefix = void 0; - var startPos = void 0; - if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { - // next element is located on the same line with separator: - // a,$$$$b - // ^ ^ - // | |-next element - // |-separator - // where $$$ is some leading trivia - // for a newly inserted node we'll maintain the same relative position comparing to separator and replace leading trivia with spaces - // a, x,$$$$b - // ^ ^ ^ - // | | |-next element - // | |-new inserted node padded with spaces - // |-separator - startPos = nextToken.end; - prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); - } - else { - // next element is located on different line that separator - // let insert position be the beginning of the line that contains next element - startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); - } + var nextNode = containingList[index + 1]; + var startPos = skipWhitespacesAndLineBreaks(sourceFile.text, nextNode.getFullStart()); // write separator and leading trivia of the next element as suffix - var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile)); - this.replaceRange(sourceFile, ts.createRange(startPos, containingList[index + 1].getStart(sourceFile)), newNode, { prefix: prefix, suffix: suffix }); + var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } else { @@ -135396,7 +139340,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_9 = function (sourceFile, node) { + var _loop_10 = 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)); @@ -135409,7 +139353,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_9(sourceFile, node); + _loop_10(sourceFile, node); } deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); @@ -135468,14 +139412,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_10 = function (i) { + var _loop_11 = 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_10(i); + _loop_11(i); } var textChanges = ts.mapDefined(normalized, function (c) { var span = ts.createTextSpanFromRange(c.range); @@ -135589,11 +139533,12 @@ var ts; function createWriter(newLine) { var lastNonTriviaPosition = 0; var writer = ts.createTextWriter(newLine); - var onEmitNode = function (hint, node, printCallback) { + var onBeforeEmitNode = function (node) { if (node) { setPos(node, lastNonTriviaPosition); } - printCallback(hint, node); + }; + var onAfterEmitNode = function (node) { if (node) { setEnd(node, lastNonTriviaPosition); } @@ -135712,7 +139657,8 @@ var ts; lastNonTriviaPosition = 0; } return { - onEmitNode: onEmitNode, + onBeforeEmitNode: onBeforeEmitNode, + onAfterEmitNode: onAfterEmitNode, onBeforeEmitNodeArray: onBeforeEmitNodeArray, onAfterEmitNodeArray: onAfterEmitNodeArray, onBeforeEmitToken: onBeforeEmitToken, @@ -135827,14 +139773,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 158 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 159 /* 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 160 /* Parameter */: { + case 161 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -135849,15 +139795,17 @@ var ts; } break; } - case 261 /* ImportDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 262 /* ImportDeclaration */: + case 261 /* 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 }); + deleteNode(changes, sourceFile, node, { + leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, + }); break; - case 198 /* BindingElement */: + case 199 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 197 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 198 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -135865,13 +139813,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 159 /* TypeParameter */: + case 160 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 265 /* ImportSpecifier */: + case 266 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -135880,7 +139828,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 263 /* NamespaceImport */: + case 264 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; case 26 /* SemicolonToken */: @@ -135889,12 +139837,16 @@ var ts; case 97 /* FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: + case 252 /* FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: - if (ts.isImportClause(node.parent) && node.parent.name === node) { + if (!node.parent) { + // a misbehaving client can reach here with the SourceFile node + deleteNode(changes, sourceFile, node); + } + else if (ts.isImportClause(node.parent) && node.parent.name === node) { deleteDefaultImport(changes, sourceFile, node.parent); } else if (ts.isCallExpression(node.parent) && ts.contains(node.parent.arguments, node)) { @@ -135937,13 +139889,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 261 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 262 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 287 /* CatchClause */) { + if (parent.kind === 288 /* 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; @@ -135954,14 +139906,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 239 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 237 /* ForStatement */: + case 238 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -136017,6 +139969,10 @@ var ts; return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, 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); + } + codefix.createCodeFixActionMaybeFixAll = createCodeFixActionMaybeFixAll; function createCodeFixActionWorker(fixName, description, changes, fixId, fixAllDescription, command) { return { fixName: fixName, description: description, changes: changes, fixId: fixId, fixAllDescription: fixAllDescription, commands: command ? [command] : undefined }; } @@ -136271,6 +140227,7 @@ var ts; ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1.code, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2.code, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined.code, ts.Diagnostics.Type_0_is_not_an_array_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type.code, ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators.code, @@ -136369,14 +140326,14 @@ var ts; } var isCompleteFix = identifiers.isCompleteFix; var initializers; - var _loop_11 = function (identifier) { + var _loop_12 = 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, 232 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 233 /* VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || @@ -136402,7 +140359,7 @@ var ts; }; for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { var identifier = _a[_i]; - _loop_11(identifier); + _loop_12(identifier); } return initializers && { initializers: initializers, @@ -136454,10 +140411,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 === 251 /* FunctionDeclaration */ || - ancestor.parent.kind === 208 /* FunctionExpression */ || - ancestor.parent.kind === 209 /* ArrowFunction */ || - ancestor.parent.kind === 165 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 252 /* FunctionDeclaration */ || + ancestor.parent.kind === 209 /* FunctionExpression */ || + ancestor.parent.kind === 210 /* ArrowFunction */ || + ancestor.parent.kind === 166 /* MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -136576,10 +140533,10 @@ var ts; function isPossiblyPartOfDestructuring(node) { switch (node.kind) { case 78 /* Identifier */: - case 199 /* ArrayLiteralExpression */: - case 200 /* ObjectLiteralExpression */: - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 200 /* ArrayLiteralExpression */: + case 201 /* ObjectLiteralExpression */: + case 289 /* PropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -136594,7 +140551,7 @@ var ts; function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { case 78 /* Identifier */: - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -136643,7 +140600,7 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 163 /* PropertyDeclaration */ && + if (declaration.kind === 164 /* PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { changeTracker.insertModifierBefore(sourceFile, 133 /* DeclareKeyword */, declaration); } @@ -136780,26 +140737,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 249 /* VariableDeclaration */ || - node.kind === 162 /* PropertySignature */ || - node.kind === 163 /* PropertyDeclaration */; + node.kind === 250 /* VariableDeclaration */ || + node.kind === 163 /* PropertySignature */ || + node.kind === 164 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 303 /* JSDocAllType */: - case 304 /* JSDocUnknownType */: + case 304 /* JSDocAllType */: + case 305 /* JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 307 /* JSDocOptionalType */: + case 308 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 306 /* JSDocNonNullableType */: + case 307 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 305 /* JSDocNullableType */: + case 306 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 309 /* JSDocVariadicType */: + case 310 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 308 /* JSDocFunctionType */: + case 309 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 173 /* TypeReference */: + case 174 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); @@ -136824,7 +140781,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 309 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 310 /* 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); @@ -136895,7 +140852,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { // Bad input return undefined; } @@ -136922,7 +140879,7 @@ var ts; // all instance members are stored in the "member" array of symbol if (symbol.members) { symbol.members.forEach(function (member, key) { - if (key === "constructor") { + if (key === "constructor" && member.valueDeclaration) { // fn.prototype.constructor = fn changes.delete(sourceFile, member.valueDeclaration.parent); return; @@ -136936,7 +140893,7 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - if (member.name === "prototype") { + if (member.name === "prototype" && member.declarations) { var firstDeclaration = member.declarations[0]; // only one "x.prototype = { ... }" will pass if (member.declarations.length === 1 && @@ -136998,7 +140955,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 === 233 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 234 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -137059,7 +141016,7 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 230 /* Block */) { + if (arrowFunctionBody.kind === 231 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -137161,7 +141118,7 @@ var ts; functionToConvert = tokenAtPosition.parent.initializer; } else { - functionToConvert = ts.tryCast(ts.getContainingFunction(ts.getTokenAtPosition(sourceFile, position)), ts.isFunctionLikeDeclaration); + functionToConvert = ts.tryCast(ts.getContainingFunction(ts.getTokenAtPosition(sourceFile, position)), ts.canBeConvertedToAsync); } if (!functionToConvert) { return; @@ -137170,6 +141127,9 @@ var ts; var isInJavascript = ts.isInJSFile(functionToConvert); var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap); + if (!ts.returnsPromise(functionToConvertRenamed, checker)) { + return; + } var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body, checker) : ts.emptyArray; var transformer = { checker: checker, synthNamesMap: synthNamesMap, setOfExpressionsToReturn: setOfExpressionsToReturn, isInJSFile: isInJavascript }; if (!returnStatements.length) { @@ -137180,7 +141140,7 @@ var ts; functionToConvert.getStart(sourceFile); var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; changes.insertModifierAt(sourceFile, pos, 129 /* AsyncKeyword */, options); - var _loop_12 = function (returnStatement) { + var _loop_13 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { var newNodes = transformExpression(node, transformer); @@ -137193,7 +141153,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var returnStatement = returnStatements_1[_i]; - _loop_12(returnStatement); + _loop_13(returnStatement); } } function getReturnStatementsWithPromiseHandlers(body, checker) { @@ -137270,7 +141230,10 @@ var ts; // so we push an entry for 'response'. if (lastCallSignature && !ts.isParameter(node.parent) && !ts.isFunctionLikeDeclaration(node.parent) && !synthNamesMap.has(symbolIdString)) { var firstParameter = ts.firstOrUndefined(lastCallSignature.parameters); - var ident = firstParameter && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) || ts.factory.createUniqueName("result", 16 /* Optimistic */); + var ident = (firstParameter === null || firstParameter === void 0 ? void 0 : firstParameter.valueDeclaration) + && ts.isParameter(firstParameter.valueDeclaration) + && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) + || ts.factory.createUniqueName("result", 16 /* Optimistic */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -137448,7 +141411,7 @@ var ts; case 103 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: case 78 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler @@ -137470,8 +141433,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: { + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_c = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _c === void 0 ? void 0 : _c.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -137690,10 +141653,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 203 /* CallExpression */: + case 204 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -137760,20 +141723,20 @@ var ts; } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 233 /* ExpressionStatement */: { + case 234 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 203 /* CallExpression */: { + case 204 /* 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 216 /* BinaryExpression */: { + case 217 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } @@ -137822,8 +141785,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: { + case 197 /* ObjectBindingPattern */: + case 198 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -137874,16 +141837,16 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 289 /* ShorthandPropertyAssignment */: - case 290 /* SpreadAssignment */: + case 290 /* ShorthandPropertyAssignment */: + case 291 /* SpreadAssignment */: return undefined; - case 288 /* PropertyAssignment */: + case 289 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(92 /* ExportKeyword */)], prop, useSitesToUnqualify); default: ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); @@ -137947,7 +141910,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { var modifiers = [ts.factory.createToken(92 /* ExportKeyword */)]; switch (exported.kind) { - case 208 /* FunctionExpression */: { + case 209 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -137955,10 +141918,10 @@ var ts; } } // falls through - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 221 /* ClassExpression */: + case 222 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -137978,7 +141941,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 === 201 /* PropertyAccessExpression */) { + if (original.kind === 202 /* 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); @@ -137993,7 +141956,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 196 /* ObjectBindingPattern */: { + case 197 /* 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 @@ -138006,7 +141969,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 197 /* ArrayBindingPattern */: { + case 198 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -138025,7 +141988,9 @@ var ts; } /** * Convert `import x = require("x").` - * Also converts uses like `x.y()` to `y()` and uses a named import. + * Also: + * - Convert `x.default()` to `x()` to handle ES6 default export + * - Converts uses like `x.y()` to `y()` and uses a named import. */ function convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference) { var nameSymbol = checker.getSymbolAtLocation(name); @@ -138042,14 +142007,21 @@ var ts; } var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { - var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` - var idName = namedBindingsNames.get(propertyName); - if (idName === undefined) { - idName = makeUniqueName(propertyName, identifiers); - namedBindingsNames.set(propertyName, idName); + var propertyName = parent.name.text; + if (propertyName === "default") { + needDefaultImport = true; + var importDefaultName = use.getText(); + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(importDefaultName)); + } + else { + ts.Debug.assert(parent.expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` + var idName = namedBindingsNames.get(propertyName); + if (idName === undefined) { + idName = makeUniqueName(propertyName, identifiers); + namedBindingsNames.set(propertyName, idName); + } + (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } - (useSitesToUnqualify !== null && useSitesToUnqualify !== void 0 ? useSitesToUnqualify : (useSitesToUnqualify = new ts.Map())).set(parent, ts.factory.createIdentifier(idName)); } else { needDefaultImport = true; @@ -138090,11 +142062,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: return parent.name !== node; - case 198 /* BindingElement */: + case 199 /* BindingElement */: return parent.propertyName !== node; - case 265 /* ImportSpecifier */: + case 266 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -138571,87 +142543,138 @@ var ts; ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting"; ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew"; })(ImportFixKind || (ImportFixKind = {})); - var ImportKind; - (function (ImportKind) { - ImportKind[ImportKind["Named"] = 0] = "Named"; - ImportKind[ImportKind["Default"] = 1] = "Default"; - ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; - ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; - })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var compilerOptions = program.getCompilerOptions(); var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name)) - ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, sourceFile, program, host)] + ? [getSymbolExportInfoForSymbol(exportedSymbol, moduleSymbol, program, host)] : getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, host, program, /*useAutoImportProvider*/ true); var useRequire = shouldUseRequire(sourceFile, program); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !ts.isSourceFileJS(sourceFile) && ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); - var moduleSpecifier = getBestFix(getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences), sourceFile, program, host).moduleSpecifier; var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: fix.moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences) { ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); - // We sort the best codefixes first, so taking `first` is best. - return getBestFix(getFixForImport(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences), sourceFile, program, host); + return getBestFix(getImportFixes(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences), sourceFile, host); } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; } - function getSymbolExportInfoForSymbol(symbol, moduleSymbol, importingFile, program, host) { + function getSymbolExportInfoForSymbol(symbol, moduleSymbol, program, host) { var _a, _b; var compilerOptions = program.getCompilerOptions(); - var mainProgramInfo = getInfoWithChecker(program.getTypeChecker()); + var mainProgramInfo = getInfoWithChecker(program.getTypeChecker(), /*isFromPackageJson*/ false); if (mainProgramInfo) { return mainProgramInfo; } var autoImportProvider = (_b = (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getTypeChecker(); - return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider), "Could not find symbol in specified module for code actions"); - function getInfoWithChecker(checker) { - var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); + return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider, /*isFromPackageJson*/ true), "Could not find symbol in specified module for code actions"); + function getInfoWithChecker(checker, isFromPackageJson) { + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && ts.skipAlias(defaultInfo.symbol, checker) === symbol) { - return { moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker) }; + return { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker) }; + return { symbol: named, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(symbol, checker), isFromPackageJson: isFromPackageJson }; } } } function getAllReExportingModules(importingFile, exportedSymbol, exportingModuleSymbol, symbolName, host, program, useAutoImportProvider) { var result = []; var compilerOptions = program.getCompilerOptions(); - forEachExternalModuleToImportFrom(program, host, importingFile, /*filterByPackageJson*/ false, useAutoImportProvider, function (moduleSymbol, moduleFile, program) { + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); + forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); // Don't import from a re-export when looking "up" like to `./index` or `../index`. if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) { return; } - var defaultInfo = getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions); - if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { - result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); } 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) { - result.push({ moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker) }); + if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + result.push({ symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); } } }); return result; + function isImportable(program, moduleFile, isFromPackageJson) { + var _a; + return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host)); + } } + function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences) { + return getBestFix(getNewImportFixes(program, importingFile, /*position*/ undefined, /*preferTypeOnlyImport*/ false, /*useRequire*/ false, exportInfo, host, preferences), importingFile, host); + } + codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo; + function getSymbolToExportInfoMap(importingFile, host, program) { + var _a, _b, _c, _d, _e, _f, _g, _h; + var start = ts.timestamp(); + // Pulling the AutoImportProvider project will trigger its updateGraph if pending, + // which will invalidate the export map cache if things change, so pull it before + // checking the cache. + (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); + var cache = (_b = host.getExportMapCache) === null || _b === void 0 ? void 0 : _b.call(host); + if (cache) { + var cached = cache.get(importingFile.path, program.getTypeChecker(), (_c = host.getProjectVersion) === null || _c === void 0 ? void 0 : _c.call(host)); + if (cached) { + (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getSymbolToExportInfoMap: cache hit"); + return cached; + } + else { + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getSymbolToExportInfoMap: cache miss or empty; calculating new results"); + } + } + var result = ts.createMultiMap(); + var compilerOptions = program.getCompilerOptions(); + var target = ts.getEmitScriptTarget(compilerOptions); + forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, _moduleFile, program, isFromPackageJson) { + var checker = program.getTypeChecker(); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); + if (defaultInfo) { + var name = ts.getNameForExportedSymbol(ts.getLocalSymbolForExportDefault(defaultInfo.symbol) || defaultInfo.symbol, target); + result.add(key(name, defaultInfo.symbol, moduleSymbol, checker), { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, exportKind: defaultInfo.exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson: isFromPackageJson }); + } + var seenExports = new ts.Map(); + for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { + var exported = _a[_i]; + if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && ts.addToSeen(seenExports, exported)) { + result.add(key(ts.getNameForExportedSymbol(exported, target), exported, moduleSymbol, checker), { symbol: exported, moduleSymbol: moduleSymbol, exportKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker), isFromPackageJson: isFromPackageJson }); + } + } + }); + if (cache) { + (_f = host.log) === null || _f === void 0 ? void 0 : _f.call(host, "getSymbolToExportInfoMap: caching results"); + cache.set(result, (_g = host.getProjectVersion) === null || _g === void 0 ? void 0 : _g.call(host)); + } + (_h = host.log) === null || _h === void 0 ? void 0 : _h.call(host, "getSymbolToExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + return result; + function key(name, alias, moduleSymbol, checker) { + var moduleName = ts.stripQuotes(moduleSymbol.name); + var moduleKey = ts.isExternalModuleNameRelative(moduleName) ? "/" : moduleName; + return name + "|" + ts.getSymbolId(ts.skipAlias(alias, checker)) + "|" + moduleKey; + } + } + codefix.getSymbolToExportInfoMap = getSymbolToExportInfoMap; function isTypeOnlySymbol(s, checker) { return !(ts.skipAlias(s, checker).flags & 111551 /* Value */); } function isTypeOnlyPosition(sourceFile, position) { return ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); } - function getFixForImport(exportInfos, symbolName, + function getImportFixes(exportInfos, symbolName, /** undefined only for missing JSX namespace */ position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); - var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); + 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)); // Don't bother providing an action to add a new import if we can add to an existing one. @@ -138674,10 +142697,11 @@ var ts; return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration; var namespacePrefix = getNamespaceLikeImportText(declaration); - if (namespacePrefix) { + var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position }; + return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -138685,11 +142709,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 261 /* ImportDeclaration */: + case 262 /* 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: @@ -138699,11 +142723,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return declaration.name.text; - case 261 /* ImportDeclaration */: + case 262 /* 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); @@ -138712,31 +142736,38 @@ var ts; function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 260 /* ImportEqualsDeclaration */) + if (declaration.kind === 261 /* ImportEqualsDeclaration */) return undefined; - if (declaration.kind === 249 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 196 /* ObjectBindingPattern */ + if (declaration.kind === 250 /* VariableDeclaration */) { + return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 197 /* ObjectBindingPattern */ ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, canUseTypeOnlyImport: false } : undefined; } var importClause = declaration.importClause; - if (!importClause) + if (!importClause || !ts.isStringLiteralLike(declaration.moduleSpecifier)) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 264 /* NamedImports */) - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.getText(), canUseTypeOnlyImport: canUseTypeOnlyImport } + // A type-only import may not have both a default and named imports, so the only way a name can + // be added to an existing type-only import is adding a named import to existing named bindings. + if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) + return undefined; + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 265 /* NamedImports */) + ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, canUseTypeOnlyImport: canUseTypeOnlyImport } : undefined; }); } - function getExistingImportDeclarations(_a, checker, sourceFile) { - var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; + function getExistingImportDeclarations(_a, checker, importingFile, compilerOptions) { + var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; // Can't use an es6 import for a type in JS. - return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { + if (exportedSymbolIsTypeOnly && ts.isSourceFileJS(importingFile)) + return ts.emptyArray; + var importKind = getImportKind(importingFile, exportKind, compilerOptions); + return ts.mapDefined(importingFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - if (ts.isRequireVariableDeclaration(i.parent, /*requireStringLiteralLikeArgument*/ true)) { + if (ts.isRequireVariableDeclaration(i.parent)) { return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind } : undefined; } - if (i.kind === 261 /* ImportDeclaration */ || i.kind === 260 /* ImportEqualsDeclaration */) { + if (i.kind === 262 /* ImportDeclaration */ || i.kind === 261 /* ImportEqualsDeclaration */) { return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; } }); @@ -138769,32 +142800,29 @@ var ts; // 5. Literally nothing to go on return true; } - function getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { + function getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); var compilerOptions = program.getCompilerOptions(); - return ts.flatMap(moduleSymbols, function (_a) { - var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; - return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, ts.createModuleSpecifierResolutionHost(program, host), preferences) + var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); + return ts.flatMap(moduleSymbols, function (exportInfo) { + return ts.moduleSpecifiers.getModuleSpecifiers(exportInfo.moduleSymbol, program.getTypeChecker(), compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs - ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.checkDefined(position, "position should be defined") } - : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, useRequire: useRequire, typeOnly: preferTypeOnlyImport }; + return exportInfo.exportedSymbolIsTypeOnly && isJs && position !== undefined + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, typeOnly: preferTypeOnlyImport, exportInfo: exportInfo }; }); }); } 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] : getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); + return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); } function newImportInfoFromExistingSpecifier(_a, preferTypeOnlyImport, useRequire) { var declaration = _a.declaration, importKind = _a.importKind; - var moduleSpecifier = declaration.kind === 261 /* ImportDeclaration */ ? declaration.moduleSpecifier : - declaration.kind === 249 /* VariableDeclaration */ ? declaration.initializer.arguments[0] : - declaration.moduleReference.kind === 272 /* ExternalModuleReference */ ? declaration.moduleReference.expression : - undefined; - return moduleSpecifier && ts.isStringLiteral(moduleSpecifier) - ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier.text, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } + var moduleSpecifier = ts.tryGetModuleSpecifierFromDeclaration(declaration); + return moduleSpecifier + ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } : undefined; } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -138802,18 +142830,18 @@ var ts; var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code ? getFixesInfoForUMDImport(context, symbolToken) : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined; - return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, context.host) }); + return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.host) }); } - function sortFixes(fixes, sourceFile, program, host) { - var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; + function sortFixes(fixes, sourceFile, host) { + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, allowsImportingSpecifier); }); } - function getBestFix(fixes, sourceFile, program, host) { + function getBestFix(fixes, sourceFile, host) { // These will always be placed first if available, and are better than other kinds if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) { return fixes[0]; } - var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; + var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, host).allowsImportingSpecifier; return fixes.reduce(function (best, fix) { return compareModuleSpecifiers(fix, best, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best; }); @@ -138833,9 +142861,9 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; + var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, exportKind: 3 /* UMD */, exportedSymbolIsTypeOnly: false, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); - var fixes = getFixForImport(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, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } function getUmdSymbol(token, checker) { @@ -138849,6 +142877,16 @@ var ts; ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } + function getImportKind(importingFile, exportKind, compilerOptions) { + switch (exportKind) { + case 0 /* Named */: return 0 /* Named */; + case 1 /* Default */: return 1 /* Default */; + case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions); + case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions); + default: return ts.Debug.assertNever(exportKind); + } + } + codefix.getImportKind = getImportKind; function getUmdImportKind(importingFile, compilerOptions) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { @@ -138878,22 +142916,22 @@ var ts; function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences; var checker = program.getTypeChecker(); - var symbolName = getSymbolName(sourceFile, checker, symbolToken); + var compilerOptions = program.getCompilerOptions(); + 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 compilerOptions = program.getCompilerOptions(); var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && ts.isValidTypeOnlyAliasUseSite(symbolToken); var useRequire = shouldUseRequire(sourceFile, program); var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; - return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); + return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } - function getSymbolName(sourceFile, checker, symbolToken) { + function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; - if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken) { + if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && compilerOptions.jsx !== 4 /* ReactJSX */ && compilerOptions.jsx !== 5 /* ReactJSXDev */) { var jsxNamespace = checker.getJsxNamespace(sourceFile); if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) { return jsxNamespace; @@ -138902,43 +142940,55 @@ var ts; return symbolToken.text; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, program, useAutoImportProvider, host) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host) { + var _a; // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); - function addSymbol(moduleSymbol, exportedSymbol, importKind, checker) { - originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); + var packageJsonFilter = ts.createPackageJsonImportFilter(fromFile, host); + var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host); + var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) { + return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host); + }); + function addSymbol(moduleSymbol, toFile, exportedSymbol, exportKind, program, isFromPackageJson) { + var moduleSpecifierResolutionHost = getModuleSpecifierResolutionHost(isFromPackageJson); + if (toFile && ts.isImportableFile(program, fromFile, toFile, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) || + !toFile && packageJsonFilter.allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost)) { + var checker = program.getTypeChecker(); + originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, exportKind: exportKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker), isFromPackageJson: isFromPackageJson }); + } } - forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, useAutoImportProvider, function (moduleSymbol, _, program) { + forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) { var checker = program.getTypeChecker(); cancellationToken.throwIfCancellationRequested(); var compilerOptions = program.getCompilerOptions(); - var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, compilerOptions); + var defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { - addSymbol(moduleSymbol, defaultInfo.symbol, defaultInfo.kind, checker); + addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson); } // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */, checker); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; } - function getDefaultLikeExportInfo(importingFile, moduleSymbol, checker, compilerOptions) { - var exported = getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions); + function getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions) { + var exported = getDefaultLikeExportWorker(moduleSymbol, checker); if (!exported) return undefined; - var symbol = exported.symbol, kind = exported.kind; + var symbol = exported.symbol, exportKind = exported.exportKind; var info = getDefaultExportInfoWorker(symbol, checker, compilerOptions); - return info && __assign({ symbol: symbol, kind: kind }, info); + return info && __assign({ symbol: symbol, exportKind: exportKind }, info); } - function getDefaultLikeExportWorker(importingFile, moduleSymbol, checker, compilerOptions) { + function getDefaultLikeExportWorker(moduleSymbol, checker) { + var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); + if (exportEquals !== moduleSymbol) + return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); if (defaultExport) - return { symbol: defaultExport, kind: 1 /* Default */ }; - var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); - return exportEquals === moduleSymbol ? undefined : { symbol: exportEquals, kind: getExportEqualsImportKind(importingFile, compilerOptions) }; + return { symbol: defaultExport, exportKind: 1 /* Default */ }; } function getExportEqualsImportKind(importingFile, compilerOptions) { var allowSyntheticDefaults = ts.getAllowSyntheticDefaultImports(compilerOptions); @@ -138957,7 +143007,8 @@ var ts; // on how to handle it. for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (ts.isImportEqualsDeclaration(statement)) { + // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration + if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { return 3 /* CommonJS */; } } @@ -139035,7 +143086,7 @@ var ts; } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) { - if (clause.kind === 196 /* ObjectBindingPattern */) { + if (clause.kind === 197 /* ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport, "default"); } @@ -139162,48 +143213,23 @@ var ts; var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, useAutoImportProvider, cb) { + function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) { var _a, _b; - forEachExternalModuleToImportFromInProgram(program, host, from, filterByPackageJson, function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); + forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); }); var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)); if (autoImportProvider) { var start = ts.timestamp(); - forEachExternalModuleToImportFromInProgram(autoImportProvider, host, from, filterByPackageJson, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); + forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; - function forEachExternalModuleToImportFromInProgram(program, host, from, filterByPackageJson, cb) { - var _a; - var filteredCount = 0; - var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); - var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host, moduleSpecifierResolutionHost); - forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, sourceFile) { - if (sourceFile === undefined) { - if (!packageJson || packageJson.allowsImportingAmbientModule(module)) { - cb(module, sourceFile); - } - else if (packageJson) { - filteredCount++; - } - } - else if (sourceFile && - sourceFile !== from && - isImportableFile(program, from, sourceFile, moduleSpecifierResolutionHost)) { - if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile)) { - cb(module, sourceFile); - } - else if (packageJson) { - filteredCount++; - } - } - }); - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); - } function forEachExternalModule(checker, allSourceFiles, cb) { for (var _i = 0, _a = checker.getAmbientModules(); _i < _a.length; _i++) { var ambient = _a[_i]; - cb(ambient, /*sourceFile*/ undefined); + if (!ts.stringContains(ambient.name, "*")) { + cb(ambient, /*sourceFile*/ undefined); + } } for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { var sourceFile = allSourceFiles_1[_b]; @@ -139212,31 +143238,6 @@ var ts; } } } - function isImportableFile(program, from, to, moduleSpecifierResolutionHost) { - var _a; - var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); - var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); - return !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, - /*preferSymlinks*/ false, function (toPath) { - var toFile = program.getSourceFile(toPath); - // Determine to import using toPath only if toPath is what we were looking at - // or there doesnt exist the file in the program by the symlink - return (toFile === to || !toFile) && - isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); - }); - } - /** - * Don't include something from a `node_modules` that isn't actually reachable by a global import. - * A relative import to node_modules is usually a bad idea. - */ - function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { - // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. - var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); - var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); - return toNodeModulesParent === undefined - || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) - || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); - } function moduleSymbolToValidIdentifier(moduleSymbol, target) { return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target); } @@ -139268,99 +143269,122 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; - function createAutoImportFilter(fromFile, program, host, moduleSpecifierResolutionHost) { - if (moduleSpecifierResolutionHost === void 0) { moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); } - var packageJsons = ((host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName)) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host)).filter(function (p) { return p.parseable; }); - var usesNodeCoreModules; - return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier, moduleSpecifierResolutionHost: moduleSpecifierResolutionHost }; - function moduleSpecifierIsCoveredByPackageJson(specifier) { - var packageName = getNodeModuleRootSpecifier(specifier); - for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { - var packageJson = packageJsons_1[_i]; - if (packageJson.has(packageName) || packageJson.has(ts.getTypesPackageName(packageName))) { - return true; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + var _a; + var fixName = "fixOverrideModifier"; + var fixAddOverrideId = "fixAddOverrideModifier"; + var fixRemoveOverrideId = "fixRemoveOverrideModifier"; + var errorCodes = [ + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code, + ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code, + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code, + ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code, + ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code + ]; + var errorCodeFixIdMap = (_a = {}, + _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers, + ], + _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code] = [ + ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a[ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Add_all_missing_override_modifiers, + ], + _a[ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code] = [ + ts.Diagnostics.Add_override_modifier, fixAddOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a[ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code] = [ + ts.Diagnostics.Remove_override_modifier, fixRemoveOverrideId, ts.Diagnostics.Remove_all_unnecessary_override_modifiers + ], + _a); + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var errorCode = context.errorCode, span = context.span, sourceFile = context.sourceFile; + var info = errorCodeFixIdMap[errorCode]; + if (!info) + return ts.emptyArray; + var descriptions = info[0], fixId = info[1], fixAllDescriptions = info[2]; + if (ts.isSourceFileJS(sourceFile)) + return ts.emptyArray; + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { return dispatchChanges(changes, context, errorCode, span.start); }); + return [ + codefix.createCodeFixActionMaybeFixAll(fixName, changes, descriptions, fixId, fixAllDescriptions) + ]; + }, + fixIds: [fixName, fixAddOverrideId, fixRemoveOverrideId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var code = diag.code, start = diag.start, file = diag.file; + var info = errorCodeFixIdMap[code]; + if (!info || info[1] !== context.fixId || ts.isSourceFileJS(file)) { + return; } - } - return false; - } - function allowsImportingAmbientModule(moduleSymbol) { - if (!packageJsons.length) { - return true; - } - var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); - var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName); - if (typeof declaringNodeModuleName === "undefined") { - return true; - } - var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); - if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { - return true; - } - return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) - || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); - } - function allowsImportingSourceFile(sourceFile) { - if (!packageJsons.length) { - return true; - } - var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName); - if (!moduleSpecifier) { - return true; - } - return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + dispatchChanges(changes, context, code, start); + }); } - /** - * Use for a specific module specifier that has already been resolved. - * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve - * the best module specifier for a given module _and_ determine if it’s importable. - */ - function allowsImportingSpecifier(moduleSpecifier) { - if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { - return true; - } - if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + }); + function dispatchChanges(changeTracker, context, errorCode, pos) { + switch (errorCode) { + case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0.code: + case ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0.code: + case ts.Diagnostics.This_parameter_property_must_have_an_override_modifier_because_it_overrides_a_member_in_base_class_0.code: + return doAddOverrideModifierChange(changeTracker, context.sourceFile, pos); + case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0.code: + case ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class.code: + return doRemoveOverrideModifierChange(changeTracker, context.sourceFile, pos); + default: + ts.Debug.fail("Unexpected error code: " + errorCode); + } + } + function doAddOverrideModifierChange(changeTracker, sourceFile, pos) { + var classElement = findContainerClassElementLike(sourceFile, pos); + var modifiers = classElement.modifiers || ts.emptyArray; + var staticModifier = ts.find(modifiers, ts.isStaticModifier); + var accessibilityModifier = ts.find(modifiers, function (m) { return ts.isAccessibilityModifier(m.kind); }); + var modifierPos = staticModifier ? staticModifier.end : + accessibilityModifier ? accessibilityModifier.end : + classElement.decorators ? ts.skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); + var options = accessibilityModifier || staticModifier ? { prefix: " " } : { suffix: " " }; + changeTracker.insertModifierAt(sourceFile, modifierPos, 156 /* OverrideKeyword */, options); + } + function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { + var classElement = findContainerClassElementLike(sourceFile, pos); + var overrideModifier = classElement.modifiers && ts.find(classElement.modifiers, function (modifier) { return modifier.kind === 156 /* OverrideKeyword */; }); + ts.Debug.assertIsDefined(overrideModifier); + changeTracker.deleteModifier(sourceFile, overrideModifier); + } + function isClassElementLikeHasJSDoc(node) { + switch (node.kind) { + case 167 /* Constructor */: + case 164 /* PropertyDeclaration */: + case 166 /* MethodDeclaration */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: return true; - } - return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); - } - function isAllowedCoreNodeModulesImport(moduleSpecifier) { - // If we’re in JavaScript, it can be difficult to tell whether the user wants to import - // from Node core modules or not. We can start by seeing if the user is actually using - // any node core modules, as opposed to simply having @types/node accidentally as a - // dependency of a dependency. - if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { - if (usesNodeCoreModules === undefined) { - usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); - } - if (usesNodeCoreModules) { - return true; - } - } - return false; - } - function getNodeModulesPackageNameFromFileName(importedFileName) { - if (!ts.stringContains(importedFileName, "node_modules")) { - return undefined; - } - var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); - if (!specifier) { - return undefined; - } - // Paths here are not node_modules, so we don’t care about them; - // returning anything will trigger a lookup in package.json. - if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { - return getNodeModuleRootSpecifier(specifier); - } - } - function getNodeModuleRootSpecifier(fullSpecifier) { - var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); - // Scoped packages - if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; - } - return components[0]; + case 161 /* Parameter */: + return ts.isParameterPropertyDeclaration(node, node.parent); + default: + return false; } } + function findContainerClassElementLike(sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var classElement = ts.findAncestor(token, function (node) { + if (ts.isClassLike(node)) + return "quit"; + return isClassElementLikeHasJSDoc(node); + }); + ts.Debug.assert(classElement && isClassElementLikeHasJSDoc(classElement)); + return classElement; + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -139476,7 +143500,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 192 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 193 /* NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -139485,11 +143509,11 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 180 /* OptionalType */ || unwrappedType.kind === 181 /* RestType */ || unwrappedType.kind === 186 /* ParenthesizedType */) { - if (unwrappedType.kind === 180 /* OptionalType */) { + while (unwrappedType.kind === 181 /* OptionalType */ || unwrappedType.kind === 182 /* RestType */ || unwrappedType.kind === 187 /* ParenthesizedType */) { + if (unwrappedType.kind === 181 /* OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 181 /* RestType */) { + else if (unwrappedType.kind === 182 /* RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; @@ -139553,7 +143577,7 @@ var ts; var checker = context.program.getTypeChecker(); var suggestedSymbol; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { - ts.Debug.assert(ts.isIdentifierOrPrivateIdentifier(node), "Expected an identifier for spelling (property access)"); + ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); if (parent.flags & 32 /* OptionalChain */) { containingType = checker.getNonNullableType(containingType); @@ -139592,7 +143616,7 @@ var ts; var suggestion = ts.symbolName(suggestedSymbol); if (!ts.isIdentifierText(suggestion, target) && ts.isPropertyAccessExpression(node.parent)) { var valDecl = suggestedSymbol.valueDeclaration; - if (ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) { + if (valDecl && ts.isNamedDeclaration(valDecl) && ts.isPrivateIdentifier(valDecl.name)) { changes.replaceNode(sourceFile, node, ts.factory.createIdentifier(suggestion)); } else { @@ -139789,19 +143813,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: - case 198 /* BindingElement */: - case 163 /* PropertyDeclaration */: - case 288 /* PropertyAssignment */: + case 250 /* VariableDeclaration */: + case 161 /* Parameter */: + case 199 /* BindingElement */: + case 164 /* PropertyDeclaration */: + case 289 /* PropertyAssignment */: return declaration.initializer; - case 280 /* JsxAttribute */: + case 281 /* JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 289 /* ShorthandPropertyAssignment */: - case 162 /* PropertySignature */: - case 291 /* EnumMember */: - case 333 /* JSDocPropertyTag */: - case 326 /* JSDocParameterTag */: + case 290 /* ShorthandPropertyAssignment */: + case 163 /* PropertySignature */: + case 292 /* EnumMember */: + case 337 /* JSDocPropertyTag */: + case 330 /* JSDocParameterTag */: return undefined; } } @@ -139902,7 +143926,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = codefix.getAllSupers(classDeclaration, checker); - var _loop_13 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -139927,9 +143951,9 @@ var ts; } } }; - for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { - var info = infos_1[_i]; - _loop_13(info); + for (var _i = 0, infos_2 = infos; _i < infos_2.length; _i++) { + var info = infos_2[_i]; + _loop_14(info); } }); })); @@ -140019,7 +144043,7 @@ var ts; function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 221 /* ClassExpression */) { + if (classDeclaration.kind === 222 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -140071,15 +144095,15 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 216 /* BinaryExpression */) { + if (token.parent.parent.kind === 217 /* 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))); - typeNode = checker.typeToTypeNode(widenedType, classDeclaration, /*flags*/ undefined); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration, 1 /* NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; } return typeNode || ts.factory.createKeywordTypeNode(128 /* AnyKeyword */); } @@ -140143,7 +144167,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(165 /* MethodDeclaration */, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); + var methodDeclaration = codefix.createSignatureDeclarationFromCallExpression(166 /* 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); @@ -140172,7 +144196,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(251 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(252 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -140259,7 +144283,10 @@ var ts; return { type: "install package", file: fileName, packageName: packageName }; } function tryGetImportedPackageName(sourceFile, pos) { - var moduleName = ts.cast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral).text; + var moduleSpecifierText = ts.tryCast(ts.getTokenAtPosition(sourceFile, pos), ts.isStringLiteral); + if (!moduleSpecifierText) + return undefined; + var moduleName = moduleSpecifierText.text; var packageName = ts.parsePackageName(moduleName).packageName; return ts.isExternalModuleNameRelative(packageName) ? undefined : packageName; } @@ -140863,7 +144890,7 @@ var ts; } function isImport(token) { return token.kind === 99 /* ImportKeyword */ - || token.kind === 78 /* Identifier */ && (token.parent.kind === 265 /* ImportSpecifier */ || token.parent.kind === 262 /* ImportClause */); + || token.kind === 78 /* Identifier */ && (token.parent.kind === 266 /* ImportSpecifier */ || token.parent.kind === 263 /* ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { @@ -140873,7 +144900,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 === 232 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 233 /* VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -140898,14 +144925,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 160 /* Parameter */: - case 159 /* TypeParameter */: + case 161 /* Parameter */: + case 160 /* TypeParameter */: return true; - case 249 /* VariableDeclaration */: { + case 250 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 239 /* ForOfStatement */: - case 238 /* ForInStatement */: + case 240 /* ForOfStatement */: + case 239 /* ForInStatement */: return true; } } @@ -140929,8 +144956,10 @@ var ts; if (ts.isParameter(parent)) { tryDeleteParameter(changes, sourceFile, parent, checker, sourceFiles, program, cancellationToken, isFixAll); } - else if (!isFixAll || !(ts.isIdentifier(token) && ts.FindAllReferences.Core.isSymbolReferencedInFile(token, checker, sourceFile))) { - changes.delete(sourceFile, ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent); + else if (!(isFixAll && ts.isIdentifier(token) && ts.FindAllReferences.Core.isSymbolReferencedInFile(token, checker, sourceFile))) { + var node = ts.isImportClause(parent) ? token : ts.isComputedPropertyName(parent) ? parent.parent : parent; + ts.Debug.assert(node !== sourceFile, "should not delete whole source file"); + changes.delete(sourceFile, node); } } function tryDeleteParameter(changes, sourceFile, parameter, checker, sourceFiles, program, cancellationToken, isFixAll) { @@ -140953,8 +144982,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: + case 166 /* MethodDeclaration */: + case 167 /* 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); @@ -140984,17 +145013,17 @@ var ts; } } return true; - case 251 /* FunctionDeclaration */: { + case 252 /* FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* FunctionExpression */: + case 210 /* 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 168 /* SetAccessor */: + case 169 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -141052,7 +145081,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 234 /* IfStatement */: + case 235 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -141063,8 +145092,8 @@ var ts; return; } // falls through - case 236 /* WhileStatement */: - case 237 /* ForStatement */: + case 237 /* WhileStatement */: + case 238 /* ForStatement */: changes.delete(sourceFile, container); return; } @@ -141137,7 +145166,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 === 305 /* JSDocNullableType */) { + if (typeNode.kind === 306 /* 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)); @@ -141157,7 +145186,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 305 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 306 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -141174,22 +145203,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 224 /* AsExpression */: - case 169 /* CallSignature */: - case 170 /* ConstructSignature */: - case 251 /* FunctionDeclaration */: - case 167 /* GetAccessor */: - case 171 /* IndexSignature */: - case 190 /* MappedType */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 160 /* Parameter */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: - case 168 /* SetAccessor */: - case 254 /* TypeAliasDeclaration */: - case 206 /* TypeAssertionExpression */: - case 249 /* VariableDeclaration */: + case 225 /* AsExpression */: + case 170 /* CallSignature */: + case 171 /* ConstructSignature */: + case 252 /* FunctionDeclaration */: + case 168 /* GetAccessor */: + case 172 /* IndexSignature */: + case 191 /* MappedType */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 161 /* Parameter */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 169 /* SetAccessor */: + case 255 /* TypeAliasDeclaration */: + case 207 /* TypeAssertionExpression */: + case 250 /* VariableDeclaration */: return true; default: return false; @@ -141204,7 +145233,7 @@ var ts; (function (codefix) { var fixId = "fixMissingCallParentheses"; var errorCodes = [ - ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, @@ -141291,14 +145320,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 97 /* FunctionKeyword */, sourceFile); break; - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -141497,7 +145526,7 @@ var ts; var typeNode = ts.getTypeNodeIfAccessible(type, parent, program, host); if (typeNode) { // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags - var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ ""); + var typeTag = ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(typeNode), /*comment*/ undefined); addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); } importAdder.writeFixes(changes); @@ -141631,13 +145660,13 @@ 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 !== 162 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 163 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; } var typeExpression = ts.factory.createJSDocTypeExpression(typeNode); - var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, "") : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, ""); + var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined); addJSDocTags(changes, sourceFile, parent, [typeTag]); } else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, ts.getEmitScriptTarget(program.getCompilerOptions()))) { @@ -141692,13 +145721,13 @@ var ts; else { var paramTags = ts.map(inferences, function (_a) { var name = _a.name, typeNode = _a.typeNode, isOptional = _a.isOptional; - return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, ""); + return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, ts.factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, /*comment*/ undefined); }); addJSDocTags(changes, sourceFile, signature, paramTags); } } function addJSDocTags(changes, sourceFile, parent, newTags) { - var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); + var comments = ts.flatMap(parent.jsDoc, function (j) { return typeof j.comment === "string" ? ts.factory.createJSDocText(j.comment) : j.comment; }); var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { var merged = tryMergeJsdocTags(tag, newTag); @@ -141706,15 +145735,15 @@ var ts; oldTags[i] = merged; return !!merged; }); }); - var tag = ts.factory.createJSDocComment(comments.join("\n"), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); - var jsDocNode = parent.kind === 209 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], (oldTags || ts.emptyArray)), unmergedNewTags))); + var jsDocNode = parent.kind === 210 /* 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 === 163 /* PropertyDeclaration */) { + if (signature.parent.kind === 164 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -141724,14 +145753,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 326 /* JSDocParameterTag */: { + case 330 /* 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 327 /* JSDocReturnTag */: + case 331 /* JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -141756,19 +145785,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 166 /* Constructor */: + case 167 /* Constructor */: searchToken = ts.findChildOfKind(containingFunction, 132 /* ConstructorKeyword */, sourceFile); break; - case 209 /* ArrowFunction */: - case 208 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 209 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 252 /* FunctionDeclaration */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: searchToken = containingFunction.name; break; } @@ -141910,24 +145939,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 215 /* PostfixUnaryExpression */: + case 216 /* PostfixUnaryExpression */: usage.isNumber = true; break; - case 214 /* PrefixUnaryExpression */: + case 215 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -141935,20 +145964,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 288 /* PropertyAssignment */: - case 289 /* ShorthandPropertyAssignment */: + case 289 /* PropertyAssignment */: + case 290 /* ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 163 /* PropertyDeclaration */: + case 164 /* PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 249 /* VariableDeclaration */: { + case 250 /* 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. @@ -142070,7 +146099,7 @@ var ts; case 56 /* BarBarToken */: case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 249 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 250 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); @@ -142098,7 +146127,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 203 /* CallExpression */) { + if (parent.kind === 204 /* CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -142201,7 +146230,7 @@ var ts; var anon = anons_1[_i]; for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { var p = _b[_a]; - props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); + props.add(p.name, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType()); } calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); @@ -142342,12 +146371,13 @@ var ts; if (!usageParam) { break; } - var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var genericParamType = genericParam.valueDeclaration ? checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration) : checker.getAnyType(); var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); if (elementType) { genericParamType = elementType; } - var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + var targetType = usageParam.type + || (usageParam.valueDeclaration ? checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration) : checker.getAnyType()); types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); } var genericReturn = checker.getReturnTypeOfSignature(genericSig); @@ -142361,7 +146391,7 @@ var ts; function getSignatureFromCalls(calls) { var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_14 = function (i) { + var _loop_15 = 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; })) { @@ -142370,7 +146400,7 @@ var ts; parameters.push(symbol); }; for (var i = 0; i < length; i++) { - _loop_14(i); + _loop_15(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); // TODO: GH#18217 @@ -142541,8 +146571,8 @@ var ts; var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 162 /* PropertySignature */: - case 163 /* PropertyDeclaration */: + case 163 /* PropertySignature */: + case 164 /* PropertyDeclaration */: var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { @@ -142556,8 +146586,8 @@ var ts; /*decorators*/ undefined, modifiers, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: { + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -142586,8 +146616,8 @@ var ts; } break; } - case 164 /* MethodSignature */: - case 165 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 166 /* 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 @@ -142617,7 +146647,7 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference)); } } break; @@ -142633,7 +146663,7 @@ var ts; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); var flags = 1 /* NoTruncation */ | 1073741824 /* NoUndefinedOptionalParameterType */ | 256 /* SuppressAnyReturnType */ | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0); - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 165 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 166 /* MethodDeclaration */, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } @@ -142717,7 +146747,7 @@ var ts; var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); - if (kind === 165 /* MethodDeclaration */) { + if (kind === 166 /* MethodDeclaration */) { return ts.factory.createMethodDeclaration( /*decorators*/ undefined, modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, ts.isInterfaceDeclaration(contextNode) ? undefined : createStubbedMethodBody(quotePreference)); @@ -142753,7 +146783,7 @@ var ts; } return parameters; } - function createMethodImplementingSignatures(signatures, name, optional, modifiers, quotePreference) { + function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) { /** 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. @@ -142784,8 +146814,13 @@ var ts; parameters.push(restParameter); } return createStubbedMethod(modifiers, name, optional, - /*typeParameters*/ undefined, parameters, - /*returnType*/ undefined, quotePreference); + /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference); + } + function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) { + if (ts.length(signatures)) { + var type = checker.getUnionType(ts.map(signatures, checker.getReturnTypeOfSignature)); + return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + } } function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) { return ts.factory.createMethodDeclaration( @@ -142912,13 +146947,13 @@ var ts; if (ts.isClassLike(container)) { var modifierFlags = ts.getEffectiveModifierFlags(declaration); if (ts.isSourceFileJS(file)) { - var modifiers = createModifiers(modifierFlags); + var modifiers = ts.createModifiers(modifierFlags); accessorModifiers = modifiers; fieldModifiers = modifiers; } else { - accessorModifiers = createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); - fieldModifiers = createModifiers(prepareModifierFlagsForField(modifierFlags)); + accessorModifiers = ts.createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); + fieldModifiers = ts.createModifiers(prepareModifierFlagsForField(modifierFlags)); } } updateFieldDeclaration(changeTracker, file, declaration, type, fieldName, fieldModifiers); @@ -142953,9 +146988,6 @@ var ts; var leftHead = isStatic ? container.name : ts.factory.createThis(); // TODO: GH#18217 return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } - function createModifiers(modifierFlags) { - return modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; - } function prepareModifierFlagsForAccessor(modifierFlags) { modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor modifierFlags &= ~8 /* Private */; @@ -143000,7 +147032,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 160 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 161 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -143090,7 +147122,7 @@ var ts; if (!superSymbol) break; var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; - var superDecl = ts.find(symbol.declarations, ts.isClassLike); + var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; res.push(superDecl); @@ -143136,7 +147168,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 203 /* CallExpression */ : 204 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 204 /* CallExpression */ : 205 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -143470,7 +147502,7 @@ var ts; function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); ts.Debug.assert(token.kind === 99 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 195 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.parent.kind === 196 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -143737,7 +147769,7 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(token); - if (symbol) { + if (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) { return symbol.valueDeclaration.parent.parent; } } @@ -143932,23 +147964,23 @@ var ts; return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var exportingModuleSymbol = ts.isSourceFile(exportNode.parent) ? exportNode.parent.symbol : exportNode.parent.parent.symbol; - var flags = ts.getSyntacticModifierFlags(exportNode); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); var wasDefault = !!(flags & 512 /* Default */); // If source file already has a default export, don't offer refactor. if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } switch (exportNode.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: { + case 252 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: + case 256 /* EnumDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 257 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 232 /* VariableStatement */: { + case 233 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -143960,6 +147992,11 @@ var ts; ts.Debug.assert(!wasDefault, "Can't have a default flag here"); return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } + case 267 /* ExportAssignment */: { + var node = exportNode; + var exp = node.expression; + return node.isExportEquals ? undefined : { exportNode: node, exportName: exp, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; + } default: return undefined; } @@ -143971,17 +148008,24 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 87 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + if (ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) { + var exp = exportNode.expression; + var spec = makeExportSpecifier(exp.text, exp.text); + changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec]))); + } + else { + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 87 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + } } else { var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 92 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 253 /* InterfaceDeclaration */: + case 252 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: + case 254 /* InterfaceDeclaration */: changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(87 /* DefaultKeyword */)); break; - case 232 /* VariableStatement */: + case 233 /* 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) { @@ -143990,15 +148034,15 @@ var ts; break; } // falls through - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 256 /* ModuleDeclaration */: + case 256 /* EnumDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 257 /* 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))); break; default: - ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); } } } @@ -144019,18 +148063,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 265 /* ImportSpecifier */: - case 270 /* ExportSpecifier */: { + case 266 /* ImportSpecifier */: + case 271 /* 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 262 /* ImportClause */: { + case 263 /* ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -144039,7 +148083,7 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 263 /* NamespaceImport */) { + else if (namedBindings.kind === 264 /* 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 */; @@ -144060,11 +148104,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 265 /* ImportSpecifier */: { + case 266 /* 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); @@ -144077,7 +148121,7 @@ var ts; } break; } - case 270 /* ExportSpecifier */: { + case 271 /* 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";` @@ -144123,14 +148167,16 @@ var ts; if (!info) return ts.emptyArray; if (!refactor.isRefactorErrorInfo(info)) { - var namespaceImport = info.kind === 263 /* NamespaceImport */; + var namespaceImport = info.kind === 264 /* NamespaceImport */; var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction; return [{ name: refactorName, description: action.description, actions: [action] }]; } if (context.preferences.provideRefactorNotApplicableReason) { return [ - { name: refactorName, description: namespaceToNamedAction.description, actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] }, - { name: refactorName, description: namedToNamespaceAction.description, actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] } + { name: refactorName, description: namespaceToNamedAction.description, + actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] }, + { name: refactorName, description: namedToNamespaceAction.description, + actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] } ]; } return ts.emptyArray; @@ -144165,7 +148211,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 263 /* NamespaceImport */) { + if (toConvert.kind === 264 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -144230,7 +148276,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_15 = function (element) { + var _loop_16 = 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); @@ -144249,7 +148295,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_15(element); + _loop_16(element); } changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -144566,27 +148612,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 164 /* MethodSignature */: { + case 165 /* MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 165 /* MethodDeclaration */: { + case 166 /* 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 169 /* CallSignature */: { + case 170 /* CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 166 /* Constructor */: { + case 167 /* Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 170 /* ConstructSignature */: { + case 171 /* ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 251 /* FunctionDeclaration */: { + case 252 /* FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.decorators, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -144638,12 +148684,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 164 /* MethodSignature */: - case 165 /* MethodDeclaration */: - case 169 /* CallSignature */: - case 166 /* Constructor */: - case 170 /* ConstructSignature */: - case 251 /* FunctionDeclaration */: + case 165 /* MethodSignature */: + case 166 /* MethodDeclaration */: + case 170 /* CallSignature */: + case 167 /* Constructor */: + case 171 /* ConstructSignature */: + case 252 /* FunctionDeclaration */: return true; } return false; @@ -144783,7 +148829,6 @@ var ts; }; } } - // Skip these since we don't have a way to report errors yet if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) { if (constantExtraction.errors.length === 0) { // Don't issue refactorings with duplicated names. @@ -144915,24 +148960,28 @@ var ts; /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array * of statements representing the minimum set of nodes needed to extract the entire span. This - * process may fail, in which case a set of errors is returned instead (these are currently - * not shown to the user, but can be used by us diagnostically) + * process may fail, in which case a set of errors is returned instead. These errors are shown to + * users if they have the provideRefactorNotApplicableReason option set. */ // exported only for tests - function getRangeToExtract(sourceFile, span, considerEmptySpans) { - if (considerEmptySpans === void 0) { considerEmptySpans = true; } + function getRangeToExtract(sourceFile, span, invoked) { + if (invoked === void 0) { invoked = true; } var length = span.length; - if (length === 0 && !considerEmptySpans) { + if (length === 0 && !invoked) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractEmpty)] }; } - var cursorRequest = length === 0 && considerEmptySpans; + var cursorRequest = length === 0 && invoked; + var startToken = ts.findFirstNonJsxWhitespaceToken(sourceFile, span.start); + var endToken = ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)); + /* If the refactoring command is invoked through a keyboard action it's safe to assume that the user is actively looking for + refactoring actions at the span location. As they may not know the exact range that will trigger a refactoring, we expand the + searched span to cover a real node range making it more likely that something useful will show up. */ + var adjustedSpan = startToken && endToken && invoked ? getAdjustedSpanFromNodes(startToken, endToken, sourceFile) : span; // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) - var startToken = ts.getTokenAtPosition(sourceFile, span.start); - var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, span); + var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan); // Do the same for the ending position - var endToken = ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)); - var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, span); + var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan); var declarations = []; // We'll modify these flags as we walk the tree to collect data // about what things need to be done as part of the extraction. @@ -144941,6 +148990,9 @@ var ts; // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (start.parent !== end.parent) { // start and end nodes belong to different subtrees return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -144975,9 +149027,6 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } - if (ts.isJSDoc(start)) { - return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; - } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -145030,20 +149079,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 163 /* PropertyDeclaration */) { + if (current.kind === 164 /* PropertyDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 160 /* Parameter */) { + else if (current.kind === 161 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 166 /* Constructor */) { + if (ctorOrMethod.kind === 167 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 165 /* MethodDeclaration */) { + else if (current.kind === 166 /* MethodDeclaration */) { if (ts.hasSyntacticModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -145086,7 +149135,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 249 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 250 /* 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`! @@ -145098,16 +149147,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; case 105 /* 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 === 203 /* CallExpression */) { + if (node.parent.kind === 204 /* 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)) { @@ -145119,7 +149168,7 @@ var ts; rangeFacts |= RangeFacts.UsesThis; } break; - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -145133,39 +149182,39 @@ var ts; } }); // falls through - case 252 /* ClassDeclaration */: - case 251 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: + case 252 /* 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 221 /* ClassExpression */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 166 /* Constructor */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: + case 222 /* ClassExpression */: + case 209 /* FunctionExpression */: + case 166 /* MethodDeclaration */: + case 167 /* Constructor */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 234 /* IfStatement */: + case 235 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 247 /* TryStatement */: + case 248 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 230 /* Block */: - if (node.parent && node.parent.kind === 247 /* TryStatement */ && node.parent.finallyBlock === node) { + case 231 /* Block */: + if (node.parent && node.parent.kind === 248 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 285 /* DefaultClause */: - case 284 /* CaseClause */: + case 286 /* DefaultClause */: + case 285 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -145177,19 +149226,19 @@ var ts; break; } switch (node.kind) { - case 187 /* ThisType */: + case 188 /* ThisType */: case 107 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 245 /* LabeledStatement */: { + case 246 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: { + case 242 /* BreakStatement */: + case 241 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -145198,20 +149247,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 241 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 242 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 213 /* AwaitExpression */: + case 214 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 219 /* YieldExpression */: + case 220 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -145228,6 +149277,18 @@ var ts; } } extractSymbol.getRangeToExtract = getRangeToExtract; + /** + * Includes the final semicolon so that the span covers statements in cases where it would otherwise + * only cover the declaration list. + */ + function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { + var start = startNode.getStart(sourceFile); + var end = endNode.getEnd(); + if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + end++; + } + return { start: start, length: end - start }; + } function getStatementOrExpressionRange(node) { if (ts.isStatement(node)) { return [node]; @@ -145265,7 +149326,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 === 160 /* Parameter */) { + if (current.kind === 161 /* 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; } @@ -145276,7 +149337,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 297 /* SourceFile */) { + if (current.kind === 298 /* SourceFile */) { return scopes; } } @@ -145366,32 +149427,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 166 /* Constructor */: + case 167 /* Constructor */: return "constructor"; - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : ts.ANONYMOUS; - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return "arrow function"; - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 167 /* GetAccessor */: + case 168 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 168 /* SetAccessor */: + case 169 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 252 /* ClassDeclaration */ + return scope.kind === 253 /* 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 === 257 /* ModuleBlock */ + return scope.kind === 258 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -145680,7 +149741,7 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 233 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 234 /* 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( @@ -145699,7 +149760,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 233 /* ExpressionStatement */) { + if (node.parent.kind === 234 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -146026,7 +150087,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: new ts.Map(), typeParameterUsages: new ts.Map(), substitutions: new ts.Map() }); substitutionsPerScope.push(new ts.Map()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 251 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 252 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -146089,7 +150150,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_16 = function (i) { + var _loop_17 = 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 @@ -146129,7 +150190,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_16(i); + _loop_17(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -146345,30 +150406,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 291 /* EnumMember */: + case 292 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 261 /* ImportDeclaration */ && - parent.kind !== 265 /* ImportSpecifier */; - case 220 /* SpreadElement */: - case 196 /* ObjectBindingPattern */: - case 198 /* BindingElement */: + return parent.kind !== 262 /* ImportDeclaration */ && + parent.kind !== 266 /* ImportSpecifier */; + case 221 /* SpreadElement */: + case 197 /* ObjectBindingPattern */: + case 199 /* BindingElement */: return false; case 78 /* Identifier */: - return parent.kind !== 198 /* BindingElement */ && - parent.kind !== 265 /* ImportSpecifier */ && - parent.kind !== 270 /* ExportSpecifier */; + return parent.kind !== 199 /* BindingElement */ && + parent.kind !== 266 /* ImportSpecifier */ && + parent.kind !== 271 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 230 /* Block */: - case 297 /* SourceFile */: - case 257 /* ModuleBlock */: - case 284 /* CaseClause */: + case 231 /* Block */: + case 298 /* SourceFile */: + case 258 /* ModuleBlock */: + case 285 /* CaseClause */: return true; default: return false; @@ -146510,7 +150571,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); - if (symbol) { + if (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) { var declaration = ts.cast(ts.first(symbol.declarations), ts.isTypeParameterDeclaration); if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) { ts.pushIfUnique(result, declaration); @@ -146533,7 +150594,7 @@ var ts; else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); - if (symbol && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } } @@ -146753,11 +150814,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: return true; - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -146818,10 +150879,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_17 = function (sourceFile) { + var _loop_18 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_18 = function (statement) { + var _loop_19 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -146843,22 +150904,22 @@ var ts; }; for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) { var statement = _c[_b]; - _loop_18(statement); + _loop_19(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_17(sourceFile); + _loop_18(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 261 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 263 /* NamespaceImport */ ? + case 262 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 264 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return node.name; - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); @@ -146889,20 +150950,20 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: return ts.factory.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 249 /* VariableDeclaration */: + case 250 /* 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 === 261 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 260 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 262 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 261 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -146972,15 +151033,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -146993,7 +151054,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 263 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 264 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -147005,7 +151066,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 === 264 /* NamedImports */) { + else if (namedBindings.kind === 265 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -147023,9 +151084,9 @@ var ts; changes.delete(sourceFile, name); } break; - case 197 /* ArrayBindingPattern */: + case 198 /* ArrayBindingPattern */: break; - case 196 /* ObjectBindingPattern */: + case 197 /* 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); } @@ -147053,6 +151114,9 @@ var ts; var oldFileNamedImports = []; var markSeenTop = ts.nodeSeenTracker(); // Needed because multiple declarations may appear in `const x = 0, y = 1;`. newFileImportsFromOldFile.forEach(function (symbol) { + if (!symbol.declarations) { + return; + } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; if (!isTopLevelDeclaration(decl)) @@ -147152,14 +151216,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 260 /* ImportEqualsDeclaration */: - case 265 /* ImportSpecifier */: - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: + case 261 /* ImportEqualsDeclaration */: + case 266 /* ImportSpecifier */: + case 263 /* ImportClause */: + case 264 /* NamespaceImport */: return true; - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 198 /* BindingElement */: + case 199 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -147171,7 +151235,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 261 /* ImportDeclaration */: { + case 262 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -147181,9 +151245,9 @@ var ts; ? ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 249 /* VariableDeclaration */: { + case 250 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -147192,7 +151256,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 263 /* NamespaceImport */) { + if (namedBindings.kind === 264 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -147204,9 +151268,9 @@ var ts; switch (name.kind) { case 78 /* Identifier */: return keep(name) ? name : undefined; - case 197 /* ArrayBindingPattern */: + case 198 /* ArrayBindingPattern */: return name; - case 196 /* ObjectBindingPattern */: { + case 197 /* 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; @@ -147263,13 +151327,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 252 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: + case 257 /* ModuleDeclaration */: + case 256 /* EnumDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 254 /* InterfaceDeclaration */: + case 261 /* ImportEqualsDeclaration */: return true; default: return false; @@ -147277,17 +151341,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 252 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: + case 257 /* ModuleDeclaration */: + case 256 /* EnumDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 254 /* InterfaceDeclaration */: + case 261 /* ImportEqualsDeclaration */: return cb(statement); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 233 /* ExpressionStatement */: { + case 234 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -147299,8 +151363,8 @@ var ts; switch (name.kind) { case 78 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 197 /* ArrayBindingPattern */: - case 196 /* ObjectBindingPattern */: + case 198 /* ArrayBindingPattern */: + case 197 /* 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); @@ -147311,9 +151375,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 249 /* VariableDeclaration */: + case 250 /* VariableDeclaration */: return d.parent.parent; - case 198 /* BindingElement */: + case 199 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -147346,23 +151410,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.factory.createModifier(92 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: return ts.factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 254 /* TypeAliasDeclaration */: + case 255 /* TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 253 /* InterfaceDeclaration */: + case 254 /* InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 233 /* ExpressionStatement */: + case 234 /* 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); @@ -147373,18 +151437,18 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 251 /* FunctionDeclaration */: - case 252 /* ClassDeclaration */: + case 252 /* FunctionDeclaration */: + case 253 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 256 /* ModuleDeclaration */: - case 255 /* EnumDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 253 /* InterfaceDeclaration */: - case 260 /* ImportEqualsDeclaration */: + case 257 /* ModuleDeclaration */: + case 256 /* EnumDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 254 /* InterfaceDeclaration */: + case 261 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 233 /* ExpressionStatement */: + case 234 /* 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); @@ -147727,15 +151791,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 203 /* CallExpression */: - case 204 /* NewExpression */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -147745,7 +151809,7 @@ var ts; } break; // x["foo"](...) - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -147764,14 +151828,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 201 /* PropertyAccessExpression */: + case 202 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 202 /* ElementAccessExpression */: + case 203 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -147813,19 +151877,20 @@ var ts; return ts.isMethodSignature(node) && (ts.isInterfaceDeclaration(node.parent) || ts.isTypeLiteralNode(node.parent)); } function isValidFunctionDeclaration(functionDeclaration, checker) { + var _a; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 165 /* MethodDeclaration */: + case 166 /* 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 (contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations.length) === 1 && isSingleImplementation(functionDeclaration, checker); + 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 166 /* Constructor */: + case 167 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -147833,8 +151898,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -147984,7 +152049,7 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; @@ -147992,7 +152057,7 @@ var ts; // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 87 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 221 /* ClassExpression */: + case 222 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -148003,25 +152068,25 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 251 /* FunctionDeclaration */: + case 252 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 87 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 165 /* MethodDeclaration */: + case 166 /* MethodDeclaration */: return [functionDeclaration.name]; - case 166 /* Constructor */: + case 167 /* Constructor */: var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 132 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 221 /* ClassExpression */) { + if (functionDeclaration.parent.kind === 222 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 208 /* FunctionExpression */: + case 209 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; @@ -148112,11 +152177,11 @@ var ts; function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 201 /* PropertyAccessExpression */: - case 202 /* ElementAccessExpression */: + case 202 /* PropertyAccessExpression */: + case 203 /* ElementAccessExpression */: return false; - case 218 /* TemplateExpression */: - case 216 /* BinaryExpression */: + case 219 /* TemplateExpression */: + case 217 /* BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -148193,7 +152258,7 @@ var ts; var templateSpans = []; var templateHead = ts.factory.createTemplateHead(headText); copyCommentFromStringLiterals(headIndexes, templateHead); - var _loop_19 = function (i) { + var _loop_20 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], stringIndexes = _c[2]; @@ -148217,7 +152282,7 @@ var ts; }; var out_i_1; for (var i = begin; i < nodes.length; i++) { - _loop_19(i); + _loop_20(i); i = out_i_1; } return ts.factory.createTemplateExpression(templateHead, templateSpans); @@ -148417,7 +152482,9 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var newNode = ts.factory.createFunctionDeclaration(func.decorators, statement.modifiers, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); + var newNode = ts.factory.createFunctionDeclaration(func.decorators, ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, statement, newNode); }); } @@ -148475,9 +152542,7 @@ var ts; function getEditsForAction(context) { var info = getInfo(context); if (info && !refactor.isRefactorErrorInfo(info)) { - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { - return t.tryInsertTypeAnnotation(context.file, info.declaration, info.returnTypeNode); - }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, t, info.declaration, info.returnTypeNode); }); return { renameFilename: undefined, renameLocation: undefined, edits: edits }; } return undefined; @@ -148502,11 +152567,26 @@ var ts; } return ts.emptyArray; } + function doChange(sourceFile, changes, declaration, typeNode) { + var closeParen = ts.findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile); + var needParens = ts.isArrowFunction(declaration) && closeParen === undefined; + var endNode = needParens ? ts.first(declaration.parameters) : closeParen; + if (endNode) { + if (needParens) { + changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* CloseParenToken */)); + } + changes.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); + } + } function getInfo(context) { if (ts.isInJSFile(context.file) || !refactor.refactorKindBeginsWith(inferReturnTypeAction.kind, context.kind)) return; var token = ts.getTokenAtPosition(context.file, context.startPosition); - var declaration = ts.findAncestor(token, isConvertibleDeclaration); + var declaration = ts.findAncestor(token, function (n) { + return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : + isConvertibleDeclaration(n); + }); if (!declaration || !declaration.body || declaration.type) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Return_type_must_be_inferred_from_a_function) }; } @@ -148515,7 +152595,6 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - ; var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; @@ -148523,10 +152602,10 @@ var ts; } function isConvertibleDeclaration(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: + case 166 /* MethodDeclaration */: return true; default: return false; @@ -148628,8 +152707,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 301 /* FirstJSDocNode */ || kid.kind > 333 /* LastJSDocNode */; }); - return child.kind < 157 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 302 /* FirstJSDocNode */ || kid.kind > 337 /* LastJSDocNode */; }); + return child.kind < 158 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -148640,7 +152719,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 157 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 158 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -148698,11 +152777,11 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(334 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(338 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { - var node = nodes_1[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; addSyntheticNodes(list._children, pos, node.pos, parent); list._children.push(node); pos = node.end; @@ -148809,13 +152888,13 @@ var ts; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { switch (context === null || context === void 0 ? void 0 : context.kind) { - case 167 /* GetAccessor */: + case 168 /* GetAccessor */: if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = ts.emptyArray; this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } return this.contextualGetAccessorDocumentationComment; - case 168 /* SetAccessor */: + case 169 /* SetAccessor */: if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = ts.emptyArray; this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); @@ -148825,9 +152904,9 @@ var ts; return this.getDocumentationComment(checker); } }; - SymbolObject.prototype.getJsDocTags = function () { + SymbolObject.prototype.getJsDocTags = function (checker) { if (this.tags === undefined) { - this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations, checker); } return this.tags; }; @@ -148988,7 +153067,7 @@ var ts; }; SignatureObject.prototype.getJsDocTags = function () { if (this.jsDocTags === undefined) { - this.jsDocTags = this.declaration ? getJsDocTags([this.declaration], this.checker) : []; + this.jsDocTags = this.declaration ? getJsDocTagsOfSignature(this.declaration, this.checker) : []; } return this.jsDocTags; }; @@ -149002,29 +153081,34 @@ var ts; function hasJSDocInheritDocTag(node) { return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; }); } - function getJsDocTags(declarations, checker) { - var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations); - if (tags.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - ts.forEachUnique(declarations, function (declaration) { - var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { return symbol.getJsDocTags(); }); - if (inheritedTags) { - tags = __spreadArray(__spreadArray([], inheritedTags), tags); - } - }); + function getJsDocTagsOfSignature(declaration, checker) { + var tags = ts.JsDoc.getJsDocTagsFromDeclarations([declaration], checker); + if (tags.length === 0 || hasJSDocInheritDocTag(declaration)) { + var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; }); + if (inheritedTags) { + tags = __spreadArray(__spreadArray([], inheritedTags), tags); + } } return tags; } function getDocumentationComment(declarations, checker) { if (!declarations) return ts.emptyArray; - var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); + var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker); if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) { - ts.forEachUnique(declarations, function (declaration) { - var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { return symbol.getDocumentationComment(checker); }); + var seenSymbols_1 = new ts.Set(); + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var declaration = declarations_4[_i]; + var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { + if (!seenSymbols_1.has(symbol)) { + seenSymbols_1.add(symbol); + return symbol.getDocumentationComment(checker); + } + }); // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); - }); + } } return doc; } @@ -149038,7 +153122,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 297 /* SourceFile */; + _this.kind = 298 /* SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -149097,10 +153181,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 251 /* FunctionDeclaration */: - case 208 /* FunctionExpression */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: + case 252 /* FunctionDeclaration */: + case 209 /* FunctionExpression */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -149120,31 +153204,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 252 /* ClassDeclaration */: - case 221 /* ClassExpression */: - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: - case 255 /* EnumDeclaration */: - case 256 /* ModuleDeclaration */: - case 260 /* ImportEqualsDeclaration */: - case 270 /* ExportSpecifier */: - case 265 /* ImportSpecifier */: - case 262 /* ImportClause */: - case 263 /* NamespaceImport */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 177 /* TypeLiteral */: + case 253 /* ClassDeclaration */: + case 222 /* ClassExpression */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: + case 256 /* EnumDeclaration */: + case 257 /* ModuleDeclaration */: + case 261 /* ImportEqualsDeclaration */: + case 271 /* ExportSpecifier */: + case 266 /* ImportSpecifier */: + case 263 /* ImportClause */: + case 264 /* NamespaceImport */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 178 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 160 /* Parameter */: + case 161 /* Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 92 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { break; } // falls through - case 249 /* VariableDeclaration */: - case 198 /* BindingElement */: { + case 250 /* VariableDeclaration */: + case 199 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -149155,12 +153239,12 @@ var ts; } } // falls through - case 291 /* EnumMember */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 292 /* EnumMember */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: addDeclaration(node); break; - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -149173,7 +153257,7 @@ var ts; } } break; - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -149185,7 +153269,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 263 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 264 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -149194,7 +153278,7 @@ var ts; } } break; - case 216 /* BinaryExpression */: + case 217 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -149288,15 +153372,7 @@ var ts; var fileName = rootFileNames_1[_i]; this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } - // store the compilation settings - this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); } - HostCache.prototype.compilationSettings = function () { - return this._compilationSettings; - }; - HostCache.prototype.getProjectReferences = function () { - return this.host.getProjectReferences && this.host.getProjectReferences(); - }; HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -149576,7 +153652,7 @@ var ts; return sourceFile; } function synchronizeHostData() { - var _a, _b; + var _a, _b, _c; ts.Debug.assert(languageServiceMode !== ts.LanguageServiceMode.Syntactic); // perform fast check if host supports it if (host.getProjectVersion) { @@ -149597,11 +153673,22 @@ var ts; // Get a fresh cache of the host information var hostCache = new HostCache(host, getCanonicalFileName); var rootFileNames = hostCache.getRootFileNames(); + var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames); - var projectReferences = hostCache.getProjectReferences(); + var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host); + var parsedCommandLines; + var parseConfigHost = { + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + fileExists: fileExists, + readFile: readFile, + readDirectory: readDirectory, + trace: ts.maybeBind(host, host.trace), + getCurrentDirectory: function () { return currentDirectory; }, + onUnRecoverableConfigFileDiagnostic: ts.noop, + }; // If the program is already up-to-date, we can reuse it - if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { return; } // IMPORTANT - It is critical from this moment onward that we do not check @@ -149609,7 +153696,6 @@ var ts; // instance. If we cancel midway through, we may end up in an inconsistent state where // the program points to old source files that have been invalidated because of // incremental parsing. - var newSettings = hostCache.compilationSettings(); // Now create a new compiler var compilerHost = { getSourceFile: getOrCreateSourceFile, @@ -149631,19 +153717,18 @@ var ts; getDirectories: function (path) { return host.getDirectories ? host.getDirectories(path) : []; }, - readDirectory: function (path, extensions, exclude, include, depth) { - ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); - return host.readDirectory(path, extensions, exclude, include, depth); - }, + readDirectory: readDirectory, onReleaseOldSourceFile: onReleaseOldSourceFile, + onReleaseParsedCommandLine: onReleaseParsedCommandLine, hasInvalidatedResolution: hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames, - trace: ts.maybeBind(host, host.trace), + trace: parseConfigHost.trace, resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames), resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives), useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect), + getParsedCommandLine: getParsedCommandLine, }; - (_b = host.setCompilerHost) === null || _b === void 0 ? void 0 : _b.call(host, compilerHost); + (_c = host.setCompilerHost) === null || _c === void 0 ? void 0 : _c.call(host, compilerHost); var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -149656,6 +153741,7 @@ var ts; // hostCache is captured in the closure for 'getOrCreateSourceFile' but it should not be used past this point. // It needs to be cleared to allow all collected snapshots to be released hostCache = undefined; + parsedCommandLines = undefined; // We reset this cache on structure invalidation so we don't hold on to outdated files for long; however we can't use the `compilerHost` above, // Because it only functions until `hostCache` is cleared, while we'll potentially need the functionality to lazily read sourcemap files during // the course of whatever called `synchronizeHostData` @@ -149664,6 +153750,36 @@ var ts; // pointers set property. program.getTypeChecker(); return; + function getParsedCommandLine(fileName) { + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var existing = parsedCommandLines === null || parsedCommandLines === void 0 ? void 0 : parsedCommandLines.get(path); + if (existing !== undefined) + return existing || undefined; + var result = host.getParsedCommandLine ? + host.getParsedCommandLine(fileName) : + getParsedCommandLineOfConfigFileUsingSourceFile(fileName); + (parsedCommandLines || (parsedCommandLines = new ts.Map())).set(path, result || false); + return result; + } + function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { + var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + if (!result) + return undefined; + result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); + result.resolvedPath = result.path; + result.originalFileName = result.fileName; + return ts.parseJsonSourceFileConfigFileContent(result, parseConfigHost, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), + /*optionsToExtend*/ undefined, ts.getNormalizedAbsolutePath(configFileName, currentDirectory)); + } + function onReleaseParsedCommandLine(configFileName, oldResolvedRef, oldOptions) { + var _a; + if (host.getParsedCommandLine) { + (_a = host.onReleaseParsedCommandLine) === null || _a === void 0 ? void 0 : _a.call(host, configFileName, oldResolvedRef, oldOptions); + } + else if (oldResolvedRef) { + onReleaseOldSourceFile(oldResolvedRef.sourceFile, oldOptions); + } + } function fileExists(fileName) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var entry = hostCache && hostCache.getEntryByPath(path); @@ -149680,11 +153796,15 @@ var ts; } return host.readFile && host.readFile(fileName); } + function readDirectory(path, extensions, exclude, include, depth) { + ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); + return host.readDirectory(path, extensions, exclude, include, depth); + } // Release any files we have acquired in the old program but are // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind); } function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); @@ -149729,8 +153849,13 @@ var ts; // We do not support the scenario where a host can modify a registered // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" - ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind."); - return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) { + return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); + } + else { + // Release old source file and fall through to aquire new file with new script kind + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind); + } } // We didn't already have the file. Fall through and acquire it from the registry. } @@ -149759,7 +153884,7 @@ var ts; // Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()); ts.forEach(program.getSourceFiles(), function (f) { - return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1); + return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind); }); program = undefined; // TODO: GH#18217 } @@ -149802,10 +153927,10 @@ var ts; synchronizeHostData(); return ts.Completions.getCompletionsAtPosition(host, program, log, getValidSourceFile(fileName), position, fullPreferences, options.triggerCharacter); } - function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { + function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences, data) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 + return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source, data: data }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source, preferences) { @@ -149832,7 +153957,7 @@ var ts; textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile), displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }), documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined, - tags: type_2.symbol ? type_2.symbol.getJsDocTags() : undefined + tags: type_2.symbol ? type_2.symbol.getJsDocTags(typeChecker) : undefined }; } var _a = typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { @@ -149851,19 +153976,23 @@ var ts; if (ts.isNewExpression(node.parent) && node.pos === node.parent.pos) { return node.parent.expression; } + if (ts.isNamedTupleMember(node.parent) && node.pos === node.parent.pos) { + return node.parent; + } return node; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { case 78 /* Identifier */: - return !ts.isLabelName(node) && !ts.isTagName(node); - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); + case 202 /* PropertyAccessExpression */: + case 158 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); case 107 /* ThisKeyword */: - case 187 /* ThisType */: + case 188 /* ThisType */: case 105 /* SuperKeyword */: + case 193 /* NamedTupleMember */: return true; default: return false; @@ -149968,15 +154097,15 @@ var ts; return undefined; } switch (node.kind) { - case 201 /* PropertyAccessExpression */: - case 157 /* QualifiedName */: + case 202 /* PropertyAccessExpression */: + case 158 /* QualifiedName */: case 10 /* StringLiteral */: case 94 /* FalseKeyword */: case 109 /* TrueKeyword */: case 103 /* NullKeyword */: case 105 /* SuperKeyword */: case 107 /* ThisKeyword */: - case 187 /* ThisType */: + case 188 /* ThisType */: case 78 /* Identifier */: break; // Cant create the text span @@ -149993,7 +154122,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 === 256 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 257 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -150021,15 +154150,7 @@ var ts; function getNavigationTree(fileName) { return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } - function isTsOrTsxFile(fileName) { - var kind = ts.getScriptKind(fileName, host); - return kind === 3 /* TS */ || kind === 4 /* TSX */; - } function getSemanticClassifications(fileName, span, format) { - if (!isTsOrTsxFile(fileName)) { - // do not run semantic classification on non-ts-or-tsx files - return []; - } synchronizeHostData(); var responseFormat = format || "original" /* Original */; if (responseFormat === "2020" /* TwentyTwenty */) { @@ -150040,10 +154161,6 @@ var ts; } } function getEncodedSemanticClassifications(fileName, span, format) { - if (!isTsOrTsxFile(fileName)) { - // do not run semantic classification on non-ts-or-tsx files - return { spans: [], endOfLineState: 0 /* None */ }; - } synchronizeHostData(); var responseFormat = format || "original" /* Original */; if (responseFormat === "original" /* Original */) { @@ -150134,13 +154251,13 @@ var ts; var formatContext = ts.formatting.getFormatContext(formatOptions, host); return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } - function organizeImports(scope, formatOptions, preferences) { + function organizeImports(args, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - ts.Debug.assert(scope.type === "file"); - var sourceFile = getValidSourceFile(scope.fileName); + ts.Debug.assert(args.type === "file"); + var sourceFile = getValidSourceFile(args.fileName); var formatContext = ts.formatting.getFormatContext(formatOptions, host); - return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); + return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } @@ -150573,6 +154690,16 @@ var ts; var file = getValidSourceFile(fileName); return ts.refactor.getEditsForRefactor(getRefactorContext(file, positionOrRange, preferences, formatOptions), refactorName, actionName); } + function toLineColumnOffset(fileName, position) { + // Go to Definition supports returning a zero-length span at position 0 for + // non-existent files. We need to special-case the conversion of position 0 + // to avoid a crash trying to get the text for that file, since this function + // otherwise assumes that 'fileName' is the name of a file that exists. + if (position === 0) { + return { line: 0, character: 0 }; + } + return sourceMapper.toLineColumnOffset(fileName, position); + } function prepareCallHierarchy(fileName, position) { synchronizeHostData(); var declarations = ts.CallHierarchy.resolveCallHierarchyDeclaration(program, ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); @@ -150645,7 +154772,7 @@ var ts; getAutoImportProvider: getAutoImportProvider, getApplicableRefactors: getApplicableRefactors, getEditsForRefactor: getEditsForRefactor, - toLineColumnOffset: sourceMapper.toLineColumnOffset, + toLineColumnOffset: toLineColumnOffset, getSourceMapper: function () { return sourceMapper; }, clearSourceMapperCache: function () { return sourceMapper.clearCache(); }, prepareCallHierarchy: prepareCallHierarchy, @@ -150716,7 +154843,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 272 /* ExternalModuleReference */ || + node.parent.kind === 273 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -150734,13 +154861,13 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 158 /* ComputedPropertyName */) { + if (node.parent.kind === 159 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through case 78 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 200 /* ObjectLiteralExpression */ || node.parent.parent.kind === 281 /* JsxAttributes */) && + (node.parent.parent.kind === 201 /* ObjectLiteralExpression */ || node.parent.parent.kind === 282 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -150782,7 +154909,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 202 /* ElementAccessExpression */ && + node.parent.kind === 203 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -150862,114 +154989,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 232 /* VariableStatement */: + case 233 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 249 /* VariableDeclaration */: - case 163 /* PropertyDeclaration */: - case 162 /* PropertySignature */: + case 250 /* VariableDeclaration */: + case 164 /* PropertyDeclaration */: + case 163 /* PropertySignature */: return spanInVariableDeclaration(node); - case 160 /* Parameter */: + case 161 /* Parameter */: return spanInParameterDeclaration(node); - case 251 /* FunctionDeclaration */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 208 /* FunctionExpression */: - case 209 /* ArrowFunction */: + case 252 /* FunctionDeclaration */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 167 /* Constructor */: + case 209 /* FunctionExpression */: + case 210 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 230 /* Block */: + case 231 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 257 /* ModuleBlock */: + case 258 /* ModuleBlock */: return spanInBlock(node); - case 287 /* CatchClause */: + case 288 /* CatchClause */: return spanInBlock(node.block); - case 233 /* ExpressionStatement */: + case 234 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 242 /* ReturnStatement */: + case 243 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 236 /* WhileStatement */: + case 237 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 235 /* DoStatement */: + case 236 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 248 /* DebuggerStatement */: + case 249 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 234 /* IfStatement */: + case 235 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 245 /* LabeledStatement */: + case 246 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 241 /* BreakStatement */: - case 240 /* ContinueStatement */: + case 242 /* BreakStatement */: + case 241 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 237 /* ForStatement */: + case 238 /* ForStatement */: return spanInForStatement(node); - case 238 /* ForInStatement */: + case 239 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 239 /* ForOfStatement */: + case 240 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 244 /* SwitchStatement */: + case 245 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 284 /* CaseClause */: - case 285 /* DefaultClause */: + case 285 /* CaseClause */: + case 286 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 247 /* TryStatement */: + case 248 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 246 /* ThrowStatement */: + case 247 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 266 /* ExportAssignment */: + case 267 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 260 /* ImportEqualsDeclaration */: + case 261 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 261 /* ImportDeclaration */: + case 262 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 267 /* ExportDeclaration */: + case 268 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 252 /* ClassDeclaration */: - case 255 /* EnumDeclaration */: - case 291 /* EnumMember */: - case 198 /* BindingElement */: + case 253 /* ClassDeclaration */: + case 256 /* EnumDeclaration */: + case 292 /* EnumMember */: + case 199 /* BindingElement */: // span on complete node return textSpan(node); - case 243 /* WithStatement */: + case 244 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 161 /* Decorator */: + case 162 /* Decorator */: return spanInNodeArray(parent.decorators); - case 196 /* ObjectBindingPattern */: - case 197 /* ArrayBindingPattern */: + case 197 /* ObjectBindingPattern */: + case 198 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 253 /* InterfaceDeclaration */: - case 254 /* TypeAliasDeclaration */: + case 254 /* InterfaceDeclaration */: + case 255 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -150999,7 +155126,7 @@ var ts; case 82 /* CatchKeyword */: case 95 /* FinallyKeyword */: return spanInNextNode(node); - case 156 /* OfKeyword */: + case 157 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -151012,13 +155139,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 === 78 /* Identifier */ || - node.kind === 220 /* SpreadElement */ || - node.kind === 288 /* PropertyAssignment */ || - node.kind === 289 /* ShorthandPropertyAssignment */) && + node.kind === 221 /* SpreadElement */ || + node.kind === 289 /* PropertyAssignment */ || + node.kind === 290 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 216 /* BinaryExpression */) { + if (node.kind === 217 /* 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 @@ -151040,22 +155167,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 235 /* DoStatement */: + case 236 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 161 /* Decorator */: + case 162 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 238 /* ForStatement */: + case 240 /* ForOfStatement */: return textSpan(node); - case 216 /* BinaryExpression */: + case 217 /* 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 209 /* ArrowFunction */: + case 210 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -151064,21 +155191,21 @@ var ts; } } switch (node.parent.kind) { - case 288 /* PropertyAssignment */: + case 289 /* 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 206 /* TypeAssertionExpression */: + case 207 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 249 /* VariableDeclaration */: - case 160 /* Parameter */: { + case 250 /* VariableDeclaration */: + case 161 /* 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)) { @@ -151086,7 +155213,7 @@ var ts; } break; } - case 216 /* BinaryExpression */: { + case 217 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -151116,7 +155243,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 238 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 239 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -151128,7 +155255,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 239 /* ForOfStatement */) { + parent.parent.kind === 240 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -151169,7 +155296,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 252 /* ClassDeclaration */ && functionDeclaration.kind !== 166 /* Constructor */); + (functionDeclaration.parent.kind === 253 /* ClassDeclaration */ && functionDeclaration.kind !== 167 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -151192,26 +155319,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 256 /* ModuleDeclaration */: + case 257 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 236 /* WhileStatement */: - case 234 /* IfStatement */: - case 238 /* ForInStatement */: + case 237 /* WhileStatement */: + case 235 /* IfStatement */: + case 239 /* 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 237 /* ForStatement */: - case 239 /* ForOfStatement */: + case 238 /* ForStatement */: + case 240 /* 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 === 250 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 251 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -151236,21 +155363,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 223 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 198 /* BindingElement */) { + if (bindingPattern.parent.kind === 199 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 197 /* ArrayBindingPattern */ && node.kind !== 196 /* ObjectBindingPattern */); - var elements = node.kind === 199 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 222 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 198 /* ArrayBindingPattern */ && node.kind !== 197 /* ObjectBindingPattern */); + var elements = node.kind === 200 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 223 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -151258,18 +155385,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 === 216 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 217 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 255 /* EnumDeclaration */: + case 256 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 252 /* ClassDeclaration */: + case 253 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 258 /* CaseBlock */: + case 259 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -151277,25 +155404,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 257 /* ModuleBlock */: + case 258 /* 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 255 /* EnumDeclaration */: - case 252 /* ClassDeclaration */: + case 256 /* EnumDeclaration */: + case 253 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 230 /* Block */: + case 231 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 287 /* CatchClause */: + case 288 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 258 /* CaseBlock */: + case 259 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -151303,7 +155430,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 196 /* ObjectBindingPattern */: + case 197 /* 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); @@ -151319,7 +155446,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 197 /* ArrayBindingPattern */: + case 198 /* 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); @@ -151334,12 +155461,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 235 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 203 /* CallExpression */ || - node.parent.kind === 204 /* NewExpression */) { + if (node.parent.kind === 236 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 204 /* CallExpression */ || + node.parent.kind === 205 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 207 /* ParenthesizedExpression */) { + if (node.parent.kind === 208 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -151348,21 +155475,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 208 /* FunctionExpression */: - case 251 /* FunctionDeclaration */: - case 209 /* ArrowFunction */: - case 165 /* MethodDeclaration */: - case 164 /* MethodSignature */: - case 167 /* GetAccessor */: - case 168 /* SetAccessor */: - case 166 /* Constructor */: - case 236 /* WhileStatement */: - case 235 /* DoStatement */: - case 237 /* ForStatement */: - case 239 /* ForOfStatement */: - case 203 /* CallExpression */: - case 204 /* NewExpression */: - case 207 /* ParenthesizedExpression */: + case 209 /* FunctionExpression */: + case 252 /* FunctionDeclaration */: + case 210 /* ArrowFunction */: + case 166 /* MethodDeclaration */: + case 165 /* MethodSignature */: + case 168 /* GetAccessor */: + case 169 /* SetAccessor */: + case 167 /* Constructor */: + case 237 /* WhileStatement */: + case 236 /* DoStatement */: + case 238 /* ForStatement */: + case 240 /* ForOfStatement */: + case 204 /* CallExpression */: + case 205 /* NewExpression */: + case 208 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -151372,20 +155499,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 288 /* PropertyAssignment */ || - node.parent.kind === 160 /* Parameter */) { + node.parent.kind === 289 /* PropertyAssignment */ || + node.parent.kind === 161 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 206 /* TypeAssertionExpression */) { + if (node.parent.kind === 207 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 235 /* DoStatement */) { + if (node.parent.kind === 236 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -151393,7 +155520,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 239 /* ForOfStatement */) { + if (node.parent.kind === 240 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -151934,11 +156061,11 @@ var ts; return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences); }); }; /** Get a string based representation of a completion list entry details */ - LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences) { + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); - return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences); + return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { @@ -153104,7 +157231,7 @@ var ts; }, 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) { - return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment); + return ts.factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment ? ts.factory.createNodeArray([ts.factory.createJSDocText(comment)]) : undefined); }, factoryDeprecation); /** @deprecated Use `factory.createComma` or the factory supplied by your transformation context instead. */ ts.createComma = ts.Debug.deprecate(function createComma(left, right) { @@ -153154,7 +157281,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 === 297 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + return ts.setTextRangePosEnd(kind === 298 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : kind === 78 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : kind === 79 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : @@ -153183,13 +157310,30 @@ var ts; // #region Renamed node Tests /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 206 /* TypeAssertionExpression */; + return node.kind === 207 /* TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", message: "Use `isTypeAssertionExpression` instead." }); // #endregion + // DEPRECATION: Renamed node tests + // DEPRECATION PLAN: + // - soft: 4.2 + // - warn: 4.3 + // - error: TBD + // #region Renamed node Tests + /** + * @deprecated Use `isMemberName` instead. + */ + ts.isIdentifierOrPrivateIdentifier = ts.Debug.deprecate(function isIdentifierOrPrivateIdentifier(node) { + return ts.isMemberName(node); + }, { + since: "4.2", + warnAfter: "4.3", + message: "Use `isMemberName` instead." + }); + // #endregion Renamed node Tests })(ts || (ts = {})); diff --git a/packages/schematics/angular/utility/latest-versions.ts b/packages/schematics/angular/utility/latest-versions.ts index 7c52791a5726..d23839cd2ef3 100644 --- a/packages/schematics/angular/utility/latest-versions.ts +++ b/packages/schematics/angular/utility/latest-versions.ts @@ -11,7 +11,7 @@ export const latestVersions = { Angular: '~12.1.0-next.4', RxJs: '~6.6.0', ZoneJs: '~0.11.4', - TypeScript: '~4.2.3', + TypeScript: '~4.3.2', TsLib: '^2.1.0', // Since @angular-devkit/build-angular and @schematics/angular are always